Add ServiceManager termination hook

Sem-Ver: feature
This commit is contained in:
Mehdi Abaakouk 2016-09-21 10:39:00 +02:00
parent b1ff9ea284
commit d08d48dd4e
1 changed files with 9 additions and 0 deletions

View File

@ -280,6 +280,11 @@ class ServiceManager(object):
pid = self._start_service(conf, worker_id)
self._running_services[conf][pid] = worker_id
try:
self.terminate()
except Exception:
LOG.exception("ServiceManager raised exception during shutdown")
LOG.debug("Killing services with signal SIGTERM")
os.killpg(0, signal.SIGTERM)
@ -299,6 +304,10 @@ class ServiceManager(object):
LOG.debug("Shutdown finish")
sys.exit(0)
@staticmethod
def terminate():
pass
def _wait_service(self):
"""Return the last died service or None"""
try: