Skip to content

Commit e6daae6

Browse files
Vladimir Kotalahornace
authored andcommitted
handle SIG{TERM,INT}
fixes #3569
1 parent 19f6e23 commit e6daae6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

docker/start.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import os
2525
import logging
2626
import multiprocessing
27+
import signal
2728
import shutil
2829
import subprocess
2930
import sys
@@ -545,12 +546,16 @@ def main():
545546
tomcat_popen.wait()
546547

547548

549+
def signal_handler(signum, frame):
550+
global tomcat_popen
551+
print("Terminating Tomcat {}".format(tomcat_popen))
552+
tomcat_popen.terminate()
553+
554+
sys.exit(1)
555+
556+
548557
if __name__ == "__main__":
549-
try:
550-
main()
551-
except KeyboardInterrupt:
552-
global tomcat_popen
553-
print("Terminating Tomcat {}".format(tomcat_popen))
554-
tomcat_popen.terminate()
555-
556-
sys.exit(1)
558+
signal.signal(signal.SIGTERM, signal_handler)
559+
signal.signal(signal.SIGINT, signal_handler)
560+
561+
main()

0 commit comments

Comments
 (0)