From ac36870a863a77b2c8cbb4a07169594504d207a7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 10 Jul 2019 22:20:24 -0400 Subject: [PATCH] Implement hup for log rotation This function was long-existent, but never used; implement it. --- node-daemon/pvcd/Daemon.py | 6 ++++++ node-daemon/pvcd/log.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/node-daemon/pvcd/Daemon.py b/node-daemon/pvcd/Daemon.py index 55419118..c6441d10 100644 --- a/node-daemon/pvcd/Daemon.py +++ b/node-daemon/pvcd/Daemon.py @@ -567,10 +567,16 @@ def cleanup(): def term(signum='', frame=''): cleanup() +# Hangup (logrotate) function +def hup(signum='', frame=''): + if config['file_logging']: + logger.hup() + # Handle signals gracefully signal.signal(signal.SIGTERM, term) signal.signal(signal.SIGINT, term) signal.signal(signal.SIGQUIT, term) +signal.signal(signal.SIGHUP, hup) ############################################################################### # PHASE 6 - Prepare host in Zookeeper diff --git a/node-daemon/pvcd/log.py b/node-daemon/pvcd/log.py index c8bc242e..64cd3836 100644 --- a/node-daemon/pvcd/log.py +++ b/node-daemon/pvcd/log.py @@ -66,7 +66,7 @@ class Logger(object): def __init__(self, config): self.config = config - if self.config['file_logging'] == 'True': + if self.config['file_logging']: self.logfile = self.config['log_directory'] + '/pvc.log' # We open the logfile for the duration of our session, but have a hup function self.writer = open(self.logfile, 'a', buffering=1)