From d93511d051d3b8abc97053bd4e66a2cf3812e8d3 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 2 Dec 2024 16:19:52 -0600 Subject: Send logs to STDOUT too. --- scripts/rqtl2/entry.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/rqtl2/entry.py b/scripts/rqtl2/entry.py index bd8f0b4..2a18aa3 100644 --- a/scripts/rqtl2/entry.py +++ b/scripts/rqtl2/entry.py @@ -1,7 +1,9 @@ """Build common script-entry structure.""" +import sys import logging from typing import Callable from argparse import Namespace +from logging import StreamHandler from redis import Redis from MySQLdb import Connection @@ -40,6 +42,17 @@ def build_main( fqjobid, f"{fqjobid}:log-messages", args.redisexpiry)) - return run_fn(dbconn, args, logger) + logger.addHandler(StreamHandler(stream=sys.stdout)) + try: + returncode = run_fn(dbconn, args, logger) + if returncode == 0: + rconn.hset(fqjobid, "status", "completed:success") + return returncode + rconn.hset(fqjobid, "status", "completed:error") + return returncode + except Exception as _exc: + logger.error("The process failed!", exc_info=True) + rconn.hset(fqjobid, "status", "completed:error") + return 4 return main -- cgit v1.2.3