diff --git a/salt/master.py b/salt/master.py index b661f1869d..7f20158d36 100644 --- a/salt/master.py +++ b/salt/master.py @@ -53,12 +53,6 @@ try: except ImportError: HAS_HALITE = False -try: - import systemd.daemon - HAS_PYTHON_SYSTEMD = True -except ImportError: - HAS_PYTHON_SYSTEMD = False - log = logging.getLogger(__name__) @@ -490,13 +484,6 @@ class ReqServer(object): self.workers.bind(self.w_uri) - try: - if HAS_PYTHON_SYSTEMD and systemd.daemon.booted(): - systemd.daemon.notify('READY=1') - except SystemError: - # Daemon wasn't started by systemd - pass - while True: try: zmq.device(zmq.QUEUE, self.clients, self.workers) diff --git a/salt/utils/process.py b/salt/utils/process.py index 6046ace8dd..fb0feef88e 100644 --- a/salt/utils/process.py +++ b/salt/utils/process.py @@ -20,6 +20,12 @@ try: except ImportError: pass +try: + import systemd.daemon + HAS_PYTHON_SYSTEMD = True +except ImportError: + HAS_PYTHON_SYSTEMD = False + def set_pidfile(pidfile, user): ''' @@ -178,6 +184,13 @@ class ProcessManager(object): # make sure to kill the subprocesses if the parent is killed signal.signal(signal.SIGTERM, self.kill_children) + try: + if HAS_PYTHON_SYSTEMD and systemd.daemon.booted(): + systemd.daemon.notify('READY=1') + except SystemError: + # Daemon wasn't started by systemd + pass + while True: try: pid, exit_status = os.wait()