3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

control: handle SIGINT for clean shutdown on ctrl-c

Closes #280.
This commit is contained in:
James Lu 2016-07-26 16:16:23 -07:00
parent fa1ce45bf3
commit a4dbd8d09f

View File

@ -29,12 +29,13 @@ def _shutdown(irc=None):
# Disconnect all our networks.
remove_network(ircobj)
def sigterm_handler(_signo, _stack_frame):
"""Handles SIGTERM gracefully by shutting down the PyLink daemon."""
log.info("Shutting down on SIGTERM.")
def sigterm_handler(signo, stack_frame):
"""Handles SIGTERM and SIGINT gracefully by shutting down the PyLink daemon."""
log.info("Shutting down on signal %s." % signo)
_shutdown()
signal.signal(signal.SIGTERM, sigterm_handler)
signal.signal(signal.SIGINT, sigterm_handler)
def _rehash():
"""Rehashes the PyLink daemon."""