Handle sigterm in nodaemon mode
When running zuul within a container it normally runs in nodaemon mode as pid 1. Currently in this mode zuul just ignores SIGTERM which is used normally to stop containers. Thus when running within OpenShift it waits for a timeout until it gets killed forcefully. Fix this by handling SIGINT and SIGTERM equally. Change-Id: I24bd8c953e734fdb9545714126d77cbcdc161bbd
This commit is contained in:
@@ -42,9 +42,10 @@ class Merger(zuul.cmd.ZuulDaemonApp):
|
||||
if self.args.command:
|
||||
self.args.nodaemon = True
|
||||
|
||||
def exit_handler(self):
|
||||
def exit_handler(self, signum, frame):
|
||||
self.merger.stop()
|
||||
self.merger.join()
|
||||
sys.exit(0)
|
||||
|
||||
def run(self):
|
||||
# See comment at top of file about zuul imports
|
||||
@@ -64,13 +65,13 @@ class Merger(zuul.cmd.ZuulDaemonApp):
|
||||
signal.signal(signal.SIGUSR2, zuul.cmd.stack_dump_handler)
|
||||
|
||||
if self.args.nodaemon:
|
||||
signal.signal(signal.SIGTERM, self.exit_handler)
|
||||
while True:
|
||||
try:
|
||||
signal.pause()
|
||||
except KeyboardInterrupt:
|
||||
print("Ctrl + C: asking merger to exit nicely...\n")
|
||||
self.exit_handler()
|
||||
sys.exit(0)
|
||||
self.exit_handler(signal.SIGINT, None)
|
||||
else:
|
||||
self.merger.join()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user