From 9fd03f5027eeb29aba6c88f6011976512f1f5d5a Mon Sep 17 00:00:00 2001 From: James Campbell Date: Thu, 18 Jul 2024 00:10:43 -0400 Subject: [PATCH] Fix config reload --- pgmon.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pgmon.py b/pgmon.py index d26ec07..f86c258 100755 --- a/pgmon.py +++ b/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)