Implement hup for log rotation

This function was long-existent, but never used; implement it.
This commit is contained in:
Joshua Boniface 2019-07-10 22:20:24 -04:00
parent 58f4222ee7
commit ac36870a86
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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)