diff --git a/backend/handler/rq_worker.py b/backend/handler/rq_worker.py new file mode 100644 index 000000000..60613a01c --- /dev/null +++ b/backend/handler/rq_worker.py @@ -0,0 +1,25 @@ +import logging +from typing import Any + +from rq import Worker + + +class _DropRegistryCleanupFilter(logging.Filter): + """Drops RQ's periodic "cleaning registries for queue" INFO line. + + The maintenance sweep still runs (crash recovery for orphaned jobs, TTL + reaping, stale worker pruning); only its log record is suppressed so it + does not flood logs on every maintenance interval. + """ + + def filter(self, record: logging.LogRecord) -> bool: + return "cleaning registries for queue" not in record.getMessage().lower() + + +class RomMWorker(Worker): + """RQ worker that silences the noisy registry-cleanup log line.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + if not any(isinstance(f, _DropRegistryCleanupFilter) for f in self.log.filters): + self.log.addFilter(_DropRegistryCleanupFilter()) diff --git a/docker/init_scripts/init b/docker/init_scripts/init index e94fd05a7..62cce1c36 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -232,9 +232,14 @@ start_bin_rq_worker() { redis_url="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}" fi - # Set PYTHONPATH so RQ can find the tasks module + # Set PYTHONPATH so RQ can find the tasks module. + # Use a worker class that drops the noisy per-sweep "cleaning registries for + # queue" log line. The maintenance interval keeps its default (~10 min) so + # orphaned STARTED jobs and stale workers are still pruned promptly, which the + # watcher's Worker.all() scan dedupe relies on. PYTHONPATH="/backend:${PYTHONPATH-}" rq worker \ --path /backend \ + --worker-class handler.rq_worker.RomMWorker \ --pid /tmp/rq_worker.pid \ --url "${redis_url}" \ --results-ttl "${TASK_RESULT_TTL:-86400}" \ diff --git a/entrypoint.sh b/entrypoint.sh index c60fc94c9..d14bfa181 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -68,9 +68,14 @@ else REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}" fi -# Set PYTHONPATH so RQ can find the tasks module +# Set PYTHONPATH so RQ can find the tasks module. +# Use a worker class that drops the noisy per-sweep "cleaning registries for +# queue" log line. The maintenance interval keeps its default (~10 min) so +# orphaned STARTED jobs and stale workers are still pruned promptly, which the +# watcher's Worker.all() scan dedupe relies on. PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \ --path /app/backend \ + --worker-class handler.rq_worker.RomMWorker \ --pid /tmp/rq_worker.pid \ --url "${REDIS_URL}" \ --logging_level "${LOGLEVEL:-INFO}" \