~maas-committers/maas/trunk

« back to all changes in this revision

Viewing changes to src/provisioningserver/service_monitor.py

  • Committer: MAAS Lander
  • Author(s): Raphael Badin
  • Date: 2015-05-28 01:19:03 UTC
  • mfrom: (3947.1.5 init-sys-bug-1459338)
  • Revision ID: maas_lander-20150528011903-8m1i450og5ypclf6
[r=andreserl,blake-rouse][bug=1459338][author=rvb] Use '/proc/1/comm' to figure out which init system is used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    ServiceRegistry,
31
31
)
32
32
from provisioningserver.logger.log import get_maas_logger
33
 
from provisioningserver.utils.shell import has_command_available
 
33
from provisioningserver.utils import get_init_system
34
34
from provisioningserver.utils.twisted import (
35
35
    asynchronous,
36
36
    synchronous,
91
91
 
92
92
    def __init__(self, init_system=None):
93
93
        if init_system is None:
94
 
            init_system = self._get_init_system()
 
94
            init_system = get_init_system()
95
95
        self.init_system = init_system
96
96
        self.service_locks = {}
97
97
 
98
 
    def _get_init_system(self):
99
 
        """Return "upstart" or "systemd" depending on the version of the
100
 
        init system the system is running."""
101
 
        if has_command_available("systemctl"):
102
 
            return "systemd"
103
 
        else:
104
 
            return "upstart"
105
 
 
106
98
    def _get_service_lock(self, service):
107
99
        """Return the lock for service."""
108
100
        if service not in self.service_locks: