Fix config reload
This commit is contained in:
parent
0d2e78fa7c
commit
9fd03f5027
10
pgmon.py
10
pgmon.py
@ -57,7 +57,7 @@ def init_logging(config):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create a common formatter
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s: %(funcName)s() line %(lineno)d: %(message)s')
|
||||
|
||||
# Set up or modify stderr logging
|
||||
if config.stderr_log_level != 'OFF':
|
||||
@ -125,12 +125,14 @@ def init_logging(config):
|
||||
# If we have no handlers, just bump the level to the max
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
logger.debug("Logging initialized")
|
||||
|
||||
#
|
||||
# PID file handling
|
||||
#
|
||||
def write_pid_file(pid_file):
|
||||
if pid_file is not None:
|
||||
logger.debug("Writing PID file: {}".format(pid_file))
|
||||
with open(pid_file, 'w') as f:
|
||||
f.write("{}".format(os.getpid()))
|
||||
|
||||
@ -143,6 +145,7 @@ def read_pid_file(pid_file):
|
||||
|
||||
def remove_pid_file(pid_file):
|
||||
if pid_file is not None:
|
||||
logger.debug("Removing PID file: {}".format(pid_file))
|
||||
os.unlink(pid_file)
|
||||
|
||||
|
||||
@ -220,6 +223,9 @@ class Config:
|
||||
self.metrics = {} # Metrics
|
||||
self.clusters = {} # Known clusters
|
||||
|
||||
# Store the commandline args to be used when reloading the config
|
||||
self.args = args
|
||||
|
||||
# Check if we have a config file
|
||||
self.config_file = args.config
|
||||
|
||||
@ -1045,7 +1051,7 @@ class Server:
|
||||
reload = False
|
||||
|
||||
# Read new config
|
||||
new_config = Config(self.config_file)
|
||||
new_config = Config(self.config.args)
|
||||
|
||||
# Re-init logging in case settings changed
|
||||
init_logging(new_config)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user