Commit 203f2fd2 authored by Antoine Catton's avatar Antoine Catton

Catch SIGTERM and raise SystemExit in submanager

This allow submanager to do some cleanup when it receive sigterm
(in this case removing pid file and killing subprocess).
parent e8a1f37d
......@@ -136,6 +136,9 @@ def usr1_handler(signum, frame):
if PROCESS.restarting is False:
PROCESS.restart()
def term_handler(signum, frame):
raise SystemExit
def main():
global PROCESS
......@@ -151,6 +154,8 @@ def main():
args = parser.parse_args()
signal.signal(signal.SIGTERM, term_handler)
if args.pidfile is not None:
with open(args.pidfile, 'w') as pid_file:
pid_file.write('%d' % os.getpid())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment