Merge pull request #16163 from gtmanfred/2014.7

move systemd notify to process
This commit is contained in:
Thomas S Hatch 2014-09-26 14:22:42 -06:00
commit e26b940642
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()