Implement hup for log rotation
This function was long-existent, but never used; implement it.
This commit is contained in:
parent
58f4222ee7
commit
ac36870a86
|
@ -567,10 +567,16 @@ def cleanup():
|
||||||
def term(signum='', frame=''):
|
def term(signum='', frame=''):
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
|
# Hangup (logrotate) function
|
||||||
|
def hup(signum='', frame=''):
|
||||||
|
if config['file_logging']:
|
||||||
|
logger.hup()
|
||||||
|
|
||||||
# Handle signals gracefully
|
# Handle signals gracefully
|
||||||
signal.signal(signal.SIGTERM, term)
|
signal.signal(signal.SIGTERM, term)
|
||||||
signal.signal(signal.SIGINT, term)
|
signal.signal(signal.SIGINT, term)
|
||||||
signal.signal(signal.SIGQUIT, term)
|
signal.signal(signal.SIGQUIT, term)
|
||||||
|
signal.signal(signal.SIGHUP, hup)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# PHASE 6 - Prepare host in Zookeeper
|
# PHASE 6 - Prepare host in Zookeeper
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Logger(object):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
if self.config['file_logging'] == 'True':
|
if self.config['file_logging']:
|
||||||
self.logfile = self.config['log_directory'] + '/pvc.log'
|
self.logfile = self.config['log_directory'] + '/pvc.log'
|
||||||
# We open the logfile for the duration of our session, but have a hup function
|
# We open the logfile for the duration of our session, but have a hup function
|
||||||
self.writer = open(self.logfile, 'a', buffering=1)
|
self.writer = open(self.logfile, 'a', buffering=1)
|
||||||
|
|
Loading…
Reference in New Issue