summary refs log tree commit diff
path: root/synapse/config/logger.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-09-25 11:38:28 +0100
committerErik Johnston <erik@matrix.org>2015-09-25 11:38:28 +0100
commita14665bde7730872627e956860be0d727a53e26d (patch)
treeeeb44967874a737bd2492b6591966a389de1aeda /synapse/config/logger.py
parentBundle in some room state in the unsigned bit of the invite when sending to i... (diff)
parentMerge pull request #289 from matrix-org/markjh/fix_sql (diff)
downloadsynapse-a14665bde7730872627e956860be0d727a53e26d.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/invite_state
Diffstat (limited to 'synapse/config/logger.py')
-rw-r--r--synapse/config/logger.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index fa542623b7..bd0c17c861 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -21,6 +21,7 @@ import logging.config
 import yaml
 from string import Template
 import os
+import signal
 
 
 DEFAULT_LOG_CONFIG = Template("""
@@ -69,7 +70,7 @@ class LoggingConfig(Config):
         self.log_config = self.abspath(config.get("log_config"))
         self.log_file = self.abspath(config.get("log_file"))
 
-    def default_config(self, config_dir_path, server_name):
+    def default_config(self, config_dir_path, server_name, **kwargs):
         log_file = self.abspath("homeserver.log")
         log_config = self.abspath(
             os.path.join(config_dir_path, server_name + ".log.config")
@@ -142,6 +143,19 @@ class LoggingConfig(Config):
                 handler = logging.handlers.RotatingFileHandler(
                     self.log_file, maxBytes=(1000 * 1000 * 100), backupCount=3
                 )
+
+                def sighup(signum, stack):
+                    logger.info("Closing log file due to SIGHUP")
+                    handler.doRollover()
+                    logger.info("Opened new log file due to SIGHUP")
+
+                # TODO(paul): obviously this is a terrible mechanism for
+                #   stealing SIGHUP, because it means no other part of synapse
+                #   can use it instead. If we want to catch SIGHUP anywhere
+                #   else as well, I'd suggest we find a nicer way to broadcast
+                #   it around.
+                if getattr(signal, "SIGHUP"):
+                    signal.signal(signal.SIGHUP, sighup)
             else:
                 handler = logging.StreamHandler()
             handler.setFormatter(formatter)