diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-03-13 12:19:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 12:19:54 +0000 |
commit | 5fc9261929efa9f5b623371b1a200c8d2d1b3f7c (patch) | |
tree | b25a162fcb5db7aaade0af6a8222eb0a61c7c5f3 | |
parent | Revert "Support registration & login with phone number" (diff) | |
parent | Reread log config on SIGHUP (diff) | |
download | synapse-5fc9261929efa9f5b623371b1a200c8d2d1b3f7c.tar.xz |
Merge pull request #1982 from matrix-org/rav/sighup_for_logconfig
Reread log config on SIGHUP
Diffstat (limited to '')
-rw-r--r-- | synapse/config/logger.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py index 77ded0ad25..e1f060d404 100644 --- a/synapse/config/logger.py +++ b/synapse/config/logger.py @@ -153,14 +153,6 @@ def setup_logging(log_config=None, log_file=None, verbosity=None): 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) @@ -169,8 +161,25 @@ def setup_logging(log_config=None, log_file=None, verbosity=None): logger.addHandler(handler) else: - with open(log_config, 'r') as f: - logging.config.dictConfig(yaml.load(f)) + def load_log_config(): + with open(log_config, 'r') as f: + logging.config.dictConfig(yaml.load(f)) + + def sighup(signum, stack): + # it might be better to use a file watcher or something for this. + logging.info("Reloading log config from %s due to SIGHUP", + log_config) + load_log_config() + + load_log_config() + + # 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) # It's critical to point twisted's internal logging somewhere, otherwise it # stacks up and leaks kup to 64K object; |