Harden auth and security controls with session auth and docs
This commit is contained in:
26
backend/app/worker/run_worker.py
Normal file
26
backend/app/worker/run_worker.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Worker entrypoint that enforces Redis URL security checks before queue consumption."""
|
||||
|
||||
from redis import Redis
|
||||
from rq import Worker
|
||||
|
||||
from app.core.config import get_settings, validate_redis_url_security
|
||||
|
||||
|
||||
def _build_worker_connection() -> Redis:
|
||||
"""Builds validated Redis connection used by RQ worker runtime."""
|
||||
|
||||
settings = get_settings()
|
||||
secure_redis_url = validate_redis_url_security(settings.redis_url)
|
||||
return Redis.from_url(secure_redis_url)
|
||||
|
||||
|
||||
def run_worker() -> None:
|
||||
"""Runs the RQ worker loop for the configured DCM processing queue."""
|
||||
|
||||
connection = _build_worker_connection()
|
||||
worker = Worker(["dcm"], connection=connection)
|
||||
worker.work()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_worker()
|
||||
Reference in New Issue
Block a user