mirror of
https://github.com/craigerl/aprsd.git
synced 2025-07-19 08:45:15 -04:00
Healthcheck command doesn't need the aprsd.yml config
This patch updates the healthcheck command to not require the aprsd.yml config file to exist. The healthcheck calls a running aprsd, collects the stats to determine if it's healthy.
This commit is contained in:
parent
152132b0ed
commit
8842fb1b44
@ -65,3 +65,24 @@ def process_standard_options(f: F) -> F:
|
|||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
return update_wrapper(t.cast(F, new_func), f)
|
return update_wrapper(t.cast(F, new_func), f)
|
||||||
|
|
||||||
|
|
||||||
|
def process_standard_options_no_config(f: F) -> F:
|
||||||
|
"""Use this as a decorator when config isn't needed."""
|
||||||
|
def new_func(*args, **kwargs):
|
||||||
|
ctx = args[0]
|
||||||
|
ctx.ensure_object(dict)
|
||||||
|
ctx.obj["loglevel"] = kwargs["loglevel"]
|
||||||
|
ctx.obj["config_file"] = kwargs["config_file"]
|
||||||
|
ctx.obj["quiet"] = kwargs["quiet"]
|
||||||
|
log.setup_logging_no_config(
|
||||||
|
ctx.obj["loglevel"],
|
||||||
|
ctx.obj["quiet"],
|
||||||
|
)
|
||||||
|
|
||||||
|
del kwargs["loglevel"]
|
||||||
|
del kwargs["config_file"]
|
||||||
|
del kwargs["quiet"]
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
return update_wrapper(t.cast(F, new_func), f)
|
||||||
|
@ -40,10 +40,9 @@ LOG = logging.getLogger("APRSD")
|
|||||||
help="How long to wait for healtcheck url to come back",
|
help="How long to wait for healtcheck url to come back",
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@cli_helper.process_standard_options
|
@cli_helper.process_standard_options_no_config
|
||||||
def healthcheck(ctx, health_url, timeout):
|
def healthcheck(ctx, health_url, timeout):
|
||||||
"""Check the health of the running aprsd server."""
|
"""Check the health of the running aprsd server."""
|
||||||
ctx.obj["config"]
|
|
||||||
LOG.debug(f"APRSD HealthCheck version: {aprsd.__version__}")
|
LOG.debug(f"APRSD HealthCheck version: {aprsd.__version__}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
17
aprsd/log.py
17
aprsd/log.py
@ -51,3 +51,20 @@ def setup_logging(config, loglevel, quiet):
|
|||||||
LOG.addHandler(sh)
|
LOG.addHandler(sh)
|
||||||
if imap_logger:
|
if imap_logger:
|
||||||
imap_logger.addHandler(sh)
|
imap_logger.addHandler(sh)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logging_no_config(loglevel, quiet):
|
||||||
|
log_level = aprsd_config.LOG_LEVELS[loglevel]
|
||||||
|
LOG.setLevel(log_level)
|
||||||
|
log_format = aprsd_config.DEFAULT_LOG_FORMAT
|
||||||
|
date_format = aprsd_config.DEFAULT_DATE_FORMAT
|
||||||
|
log_formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
|
||||||
|
fh = NullHandler()
|
||||||
|
|
||||||
|
fh.setFormatter(log_formatter)
|
||||||
|
LOG.addHandler(fh)
|
||||||
|
|
||||||
|
if not quiet:
|
||||||
|
sh = logging.StreamHandler(sys.stdout)
|
||||||
|
sh.setFormatter(log_formatter)
|
||||||
|
LOG.addHandler(sh)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user