Cleanly shutdown zuul scheduler if startup fails
At the moment, sys.exit is used to terminate the scheduler in case an exception is thrown during startup phase. However, since not all remaining threads were either daemonized or stopped, sys.exit waited indefinitely. This change uses Scheduler.stop before exiting so that all non-daemonized threads are terminated before exit. Change-Id: I9e1a753e897276b0b0f5c1b5735d05f1cfa8f9f1
This commit is contained in:
parent
bdcd29b8fe
commit
12c51791c2
|
@ -159,6 +159,7 @@ class Scheduler(zuul.cmd.ZuulDaemonApp):
|
|||
self.log.exception("Error starting Zuul:")
|
||||
# TODO(jeblair): If we had all threads marked as daemon,
|
||||
# we might be able to have a nicer way of exiting here.
|
||||
self.sched.stop()
|
||||
sys.exit(1)
|
||||
|
||||
signal.signal(signal.SIGHUP, self.reconfigure_handler)
|
||||
|
|
|
@ -230,6 +230,7 @@ class Scheduler(threading.Thread):
|
|||
self.statsd = get_statsd(config)
|
||||
self.rpc = rpclistener.RPCListener(config, self)
|
||||
self.stats_thread = threading.Thread(target=self.runStats)
|
||||
self.stats_thread.daemon = True
|
||||
self.stats_stop = threading.Event()
|
||||
# TODO(jeblair): fix this
|
||||
# Despite triggers being part of the pipeline, there is one trigger set
|
||||
|
|
Loading…
Reference in New Issue