mirror of
https://github.com/rommapp/romm.git
synced 2026-12-03 10:33:22 +01:00
Merge pull request #3731 from rommapp/posthog-code/optimize-cleanup-frequency-and-logging
Reduce RQ worker registry sweep verbosity and frequency
This commit is contained in:
25
backend/handler/rq_worker.py
Normal file
25
backend/handler/rq_worker.py
Normal file
@@ -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())
|
||||
@@ -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}" \
|
||||
|
||||
@@ -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}" \
|
||||
|
||||
Reference in New Issue
Block a user