summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-02-28 22:23:25 +0100
committermathieui <mathieui@mathieui.net>2013-02-28 22:23:25 +0100
commitabfd50aacd3e6cbe650461006843e8a394b78318 (patch)
tree82296c672dba3fbb128f1ce7a6d85d9ed846887b /src
parentde11a00a8e6d448dbe909d5f96f04bdda9d8e8ec (diff)
downloadpoezio-abfd50aacd3e6cbe650461006843e8a394b78318.tar.gz
poezio-abfd50aacd3e6cbe650461006843e8a394b78318.tar.bz2
poezio-abfd50aacd3e6cbe650461006843e8a394b78318.tar.xz
poezio-abfd50aacd3e6cbe650461006843e8a394b78318.zip
Fix signal handling
- reload the config/theme with SIGUSR1 - quit properly with SIGHUP/SIGTERM
Diffstat (limited to 'src')
-rw-r--r--src/core.py13
-rw-r--r--src/poezio.py4
2 files changed, 13 insertions, 4 deletions
diff --git a/src/core.py b/src/core.py
index 4d1bf45a..05814f19 100644
--- a/src/core.py
+++ b/src/core.py
@@ -268,12 +268,12 @@ class Core(object):
self.pending_invites = {}
- def sighup_handler(self, num, stack):
+ def sigusr_handler(self, num, stack):
"""
- Handle SIGHUP (1)
+ Handle SIGUSR1 (10)
When caught, reload all the possible files.
"""
- log.debug("SIGHUP caught, reloading the files…")
+ log.debug("SIGUSR1 caught, reloading the files…")
# reload all log files
log.debug("Reloading the log files…")
logger.reload_all()
@@ -287,6 +287,13 @@ class Core(object):
config.__init__(config.file_name)
log.debug("Config reloaded.")
+ def exit_from_signal(self, *args, **kwargs):
+ """
+ Quit when receiving SIGHUP or SIGTERM
+ """
+ log.debug("Either SIGHUP or SIGTERM received. Exiting…")
+ self.command_quit()
+
def autoload_plugins(self):
"""
Load the plugins on startup.
diff --git a/src/poezio.py b/src/poezio.py
index 258a25e4..161446da 100644
--- a/src/poezio.py
+++ b/src/poezio.py
@@ -31,7 +31,9 @@ def main():
else:
logging.basicConfig(level=logging.CRITICAL)
cocore = singleton.Singleton(core.Core)
- signal.signal(signal.SIGHUP, cocore.sighup_handler) # ignore ctrl-c
+ signal.signal(signal.SIGUSR1, cocore.sigusr_handler) # reload the config
+ signal.signal(signal.SIGHUP, cocore.exit_from_signal)
+ signal.signal(signal.SIGTERM, cocore.exit_from_signal)
if options.debug:
cocore.debug = True
cocore.start()