Merge pull request #197 from abhi1693/copilot/fix-rq-worker-scheduler-flag

fix: Use custom worker script for scheduled job processing
This commit is contained in:
Abhimanyu Saharan
2026-03-03 00:02:44 +05:30
committed by GitHub
3 changed files with 57 additions and 1 deletions
+4
View File
@@ -42,6 +42,10 @@ COPY backend/app ./app
# In-repo these live at `backend/templates/`; runtime path is `/app/templates`.
COPY backend/templates ./templates
# Copy worker scripts.
# In-repo these live at `scripts/`; runtime path is `/app/scripts`.
COPY scripts ./scripts
# Default API port
EXPOSE 8000
+1 -1
View File
@@ -75,7 +75,7 @@ services:
build:
context: .
dockerfile: backend/Dockerfile
command: ["rq", "worker", "-u", "redis://redis:6379/0"]
command: ["python", "scripts/rq-docker", "worker"]
env_file:
- ./backend/.env
depends_on:
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""RQ worker entrypoint for Docker containers."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
# In Docker, the working directory is /app and app code is at /app/app/
# Add /app to sys.path so we can import app.services.queue_worker
WORKDIR = Path.cwd()
sys.path.insert(0, str(WORKDIR))
from app.services.queue_worker import run_worker
def cmd_worker(args: argparse.Namespace) -> int:
try:
run_worker()
except KeyboardInterrupt:
return 0
return 0
def build_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="RQ background worker helpers.")
subparsers = parser.add_subparsers(dest="command", required=True)
worker_parser = subparsers.add_parser(
"worker",
help="Continuously process queued background work.",
)
worker_parser.set_defaults(func=cmd_worker)
return parser
def main() -> None:
parser = build_parser()
args = parser.parse_args()
try:
sys.exit(args.func(args))
except Exception:
# Log unexpected errors before exiting
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
main()