Support SIGINT to gracefully stop nodepoold
Nodepoold can be gracefully stopped by sending SIGUSR1. Ian Wienand suggested to use SIGINT instead which is sent to the process when pressing CTRL+C. SIGUSR* signals are usually to trigger more interesting thing such as SIGUSR2 generating traces. Register SIGINT to exit nodepoold Stop catching KeyboardInterupt exception since CTRL+C emits a SIGINT anyway. Keep SIGUSR1 registered for now, removing it would be a breaking change requiring users to adjust their initd/systemd scripts. Change-Id: Ic403b9cc74bc991b682819bc4663bb4630933a8e
This commit is contained in:
@@ -120,17 +120,17 @@ class NodePoolDaemon(object):
|
||||
self.setup_logging()
|
||||
self.pool = nodepool.nodepool.NodePool(self.args.config)
|
||||
|
||||
signal.signal(signal.SIGINT, self.exit_handler)
|
||||
# For back compatibility:
|
||||
signal.signal(signal.SIGUSR1, self.exit_handler)
|
||||
|
||||
signal.signal(signal.SIGUSR2, stack_dump_handler)
|
||||
signal.signal(signal.SIGTERM, self.term_handler)
|
||||
|
||||
self.pool.start()
|
||||
|
||||
while True:
|
||||
try:
|
||||
signal.pause()
|
||||
except KeyboardInterrupt:
|
||||
return self.exit_handler(signal.SIGINT, None)
|
||||
signal.pause()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user