Skip to content

Commit a987fed

Browse files
committed
convert signal handling to synchronous
1 parent 5acf3a4 commit a987fed

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

docker/start.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -571,30 +571,21 @@ def main():
571571

572572
start_rest_thread(logger)
573573

574-
# Ideally the signal handlers should be installed as early as possible,
575-
# however that does not play well with the worker pool communication used by do_sync().
576-
signal.signal(signal.SIGTERM, signal_handler)
577-
signal.signal(signal.SIGINT, signal_handler)
578-
579-
# Start Tomcat last. It will be the foreground process.
574+
# Start Tomcat last.
580575
logger.info("Starting Tomcat")
581-
global tomcat_popen
582576
tomcat_popen = subprocess.Popen([os.path.join(tomcat_root, 'bin',
583577
'catalina.sh'),
584578
'run'])
585-
tomcat_popen.wait()
586-
587579

588-
def signal_handler(signum, frame):
589-
print("Received signal {}".format(signum))
590-
591-
global tomcat_popen
580+
sigset = set()
581+
sigset.add(signal.SIGTERM)
582+
sigset.add(signal.SIGINT)
583+
signum = signal.sigwait(sigset)
584+
logger.info("Received signal {}".format(signum))
592585
if tomcat_popen:
593-
print("Terminating Tomcat {}".format(tomcat_popen))
586+
logger.info("Terminating Tomcat {}".format(tomcat_popen))
594587
tomcat_popen.terminate()
595588

596-
sys.exit(0)
597-
598589

599590
if __name__ == "__main__":
600591
main()

0 commit comments

Comments
 (0)