From f1f77d22cf74648eb917a0dff8669f15ca4910a4 Mon Sep 17 00:00:00 2001 From: Fritz Mueller Date: Thu, 28 Jul 2022 04:15:27 +0000 Subject: [PATCH] Add entrypoint log config for workers --- src/admin/python/lsst/qserv/admin/cli/entrypoint.py | 4 ++++ src/admin/python/lsst/qserv/admin/cli/script.py | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/admin/python/lsst/qserv/admin/cli/entrypoint.py b/src/admin/python/lsst/qserv/admin/cli/entrypoint.py index 61991d7662..559cf35c31 100644 --- a/src/admin/python/lsst/qserv/admin/cli/entrypoint.py +++ b/src/admin/python/lsst/qserv/admin/cli/entrypoint.py @@ -590,6 +590,7 @@ def worker_cmsd(ctx: click.Context, **kwargs: Any) -> None: @cmsd_worker_cfg_path_option() @xrdssi_cfg_file_option() @xrdssi_cfg_path_option() +@log_cfg_file_option() @targs_options() @cmd_options() @options_file_option() @@ -608,6 +609,7 @@ def worker_xrootd(ctx: click.Context, **kwargs: Any) -> None: cmsd_worker_cfg_path=targs["cmsd_worker_cfg_path"], xrdssi_cfg_file=targs["xrdssi_cfg_file"], xrdssi_cfg_path=targs["xrdssi_cfg_path"], + log_cfg_file=targs["log_cfg_file"], cmd=targs["cmd"], ) @@ -631,6 +633,7 @@ def worker_xrootd(ctx: click.Context, **kwargs: Any) -> None: default="{{repl_connection}}", show_default=True, ) +@log_cfg_file_option() @targs_options() @run_option() @options_file_option() @@ -641,6 +644,7 @@ def worker_repl(ctx: click.Context, **kwargs: Any) -> None: db_admin_uri=targs["db_admin_uri"], repl_connection=targs["repl_connection"], debug_port=targs["debug_port"], + log_cfg_file=targs["log_cfg_file"], cmd=targs["cmd"], run=targs["run"], ) diff --git a/src/admin/python/lsst/qserv/admin/cli/script.py b/src/admin/python/lsst/qserv/admin/cli/script.py index b0045d008f..5223813f06 100644 --- a/src/admin/python/lsst/qserv/admin/cli/script.py +++ b/src/admin/python/lsst/qserv/admin/cli/script.py @@ -393,6 +393,7 @@ def enter_worker_xrootd( cmsd_worker_cfg_path: str, xrdssi_cfg_file: str, xrdssi_cfg_path: str, + log_cfg_file: str, cmd: str, ) -> None: """Start a worker xrootd node. @@ -422,6 +423,8 @@ def enter_worker_xrootd( The path to the xrdssi config file. xrdssi_cfg_path : str The location to render to the xrdssi config file. + log_cfg_file : `str` + Location of the log4cxx config file. cmd : `str` The jinja2 template for the command for this function to execute. """ @@ -463,13 +466,15 @@ def enter_worker_xrootd( apply_template_cfg_file(cmsd_worker_cfg_file, cmsd_worker_cfg_path) apply_template_cfg_file(xrdssi_cfg_file, xrdssi_cfg_path) - sys.exit(_run(args=None, cmd=cmd)) + env = dict(os.environ, LSST_LOG_CONFIG=log_cfg_file) + sys.exit(_run(args=None, env=env, cmd=cmd)) def enter_worker_repl( db_admin_uri: str, repl_connection: str, debug_port: Optional[int], + log_cfg_file: str, cmd: str, run: bool, ) -> None: @@ -488,6 +493,8 @@ def enter_worker_repl( "qsreplica". debug_port : int or None If not None, indicates that gdbserver should be run on the given port number. + log_cfg_file : `str` + Location of the log4cxx config file. cmd : `str` The jinja2 template for the command for this function to execute. run : `bool` @@ -524,6 +531,8 @@ def enter_worker_repl( if not os.path.exists(ingest_folder): os.makedirs(ingest_folder) + env = dict(os.environ, LSST_LOG_CONFIG=log_cfg_file) + while True: # This loop exists because it is possible for qserv-replica-worker to # register itself with the replica controller before the call to @@ -534,7 +543,7 @@ def enter_worker_repl( # qserv-replica-worker returned then by definition it failed, and we # just wait a moment and restart it. # This is recorded in DM-31252 - _run(args=None, cmd=cmd, run=run) + _run(args=None, cmd=cmd, env=env, run=run) _log.info("qserv-replica-worker exited. waiting 5 seconds and restarting.") time.sleep(5)