move systemd notify to process

This commit is contained in:
Daniel Wallace 2014-09-25 16:46:27 -05:00
parent 227c62b4ee
commit 822e4395ed
2 changed files with 13 additions and 13 deletions

View File

@ -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)

View File

@ -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()