diff options
author | Tobias Henkel <tobias.henkel@bmw.de> | 2017-12-18 08:10:43 +0100 |
---|---|---|
committer | Tobias Henkel <tobias.henkel@bmw.de> | 2017-12-18 08:41:47 +0100 |
commit | fd7101b3b5065d009d3241470fca7069f6ec52f6 (patch) | |
tree | 801e4ea663d325cfab5fea68b2d4bb68bec38704 /zuul/cmd/executor.py | |
parent | 6abc1fb9d61374147fcd763c7299b2d5e90c0a0a (diff) | |
download | zuul-fd7101b3b5065d009d3241470fca7069f6ec52f6.tar.gz |
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
Diffstat (limited to 'zuul/cmd/executor.py')
-rwxr-xr-x | zuul/cmd/executor.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py index ade9715c2..c82deb748 100755 --- a/zuul/cmd/executor.py +++ b/zuul/cmd/executor.py @@ -51,9 +51,10 @@ class Executor(zuul.cmd.ZuulDaemonApp): if self.args.command: self.args.nodaemon = True - def exit_handler(self): + def exit_handler(self, signum, frame): self.executor.stop() self.executor.join() + sys.exit(0) def start_log_streamer(self): pipe_read, pipe_write = os.pipe() @@ -132,13 +133,13 @@ class Executor(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 executor to exit nicely...\n") - self.exit_handler() - sys.exit(0) + self.exit_handler(signal.SIGINT, None) else: self.executor.join() |