From 3eb97346b92b588beb451449d67aab30b30ad6f3 Mon Sep 17 00:00:00 2001 From: sshambar Date: Sun, 8 Sep 2019 18:39:28 +0100 Subject: [PATCH] Fix engine to exit correctly on Terminate signal (#442) Re-send SIGTERM to self after exiting main loop so process exits with expected exit code. --- bin/weewx/engine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/weewx/engine.py b/bin/weewx/engine.py index 6b750bcb..81b8d5c7 100644 --- a/bin/weewx/engine.py +++ b/bin/weewx/engine.py @@ -953,8 +953,9 @@ def main(options, args, engine_class=StdEngine): except Terminate: syslog.syslog(syslog.LOG_INFO, "engine: Terminating weewx version %s" % weewx.__version__) weeutil.weeutil.log_traceback(" **** ", syslog.LOG_DEBUG) - # Reraise the exception (this should cause the program to exit) - raise + # Reraise the signal (this should cause the program to exit) + signal.signal(signal.SIGTERM, signal.SIG_DFL) + os.kill(0, signal.SIGTERM) # Catch any keyboard interrupts and log them except KeyboardInterrupt: