From 1c944a7f890da1a40995eb37624e4b72676b6f76 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 8 Apr 2025 14:05:46 -0500 Subject: Add logging to worker. --- gn3/commands.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gn3/commands.py') diff --git a/gn3/commands.py b/gn3/commands.py index 71a4d27..eba01b1 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -176,12 +176,20 @@ def run_cmd(cmd: str, success_codes: Tuple = (0,), env: Optional[str] = None) -> def run_async_cmd( conn: Redis, job_queue: str, cmd: Union[str, Sequence[str]], - email: Optional[str] = None, env: Optional[dict] = None) -> str: + email: Optional[str] = None, log_level: str = "info", + env: Optional[dict] = None) -> str: """A utility function to call `gn3.commands.queue_cmd` function and run the worker in the `one-shot` mode.""" cmd_id = queue_cmd(conn, job_queue, cmd, email, env) + worker_command = [ + sys.executable, + "-m", "sheepdog.worker", + "--queue-name", job_queue, + "--log-level", log_level + ] + logging.debug("Launching the worker: %s", worker_command) subprocess.Popen( # pylint: disable=[consider-using-with] - [sys.executable, "-m", "sheepdog.worker", "--queue-name", job_queue]) + worker_command) return cmd_id -- cgit 1.4.1