feat: implement background scheduler for job scraping with Gunicorn support
Some checks failed
CI/CD Pipeline / test (push) Failing after 13s
CI/CD Pipeline / build-image (push) Has been skipped

This commit is contained in:
2026-01-21 19:07:43 +01:00
parent e8baeb3bcf
commit d84b8f128b
6 changed files with 84 additions and 6 deletions

View File

@@ -36,3 +36,17 @@ certfile = None
# Application
wsgi_module = "web.app:app"
callable = "app"
def when_ready(server):
"""Start background scheduler once in Gunicorn master if enabled."""
import os
flag = (os.environ.get("SCRAPE_SCHEDULER_ENABLED") or "").strip().lower()
if flag not in {"1", "true", "yes", "on"}:
return
try:
from web.craigslist import start_scheduler_in_background
start_scheduler_in_background()
server.log.info("Background scraper scheduler started in Gunicorn master.")
except Exception as exc:
server.log.warning("Failed to start background scraper scheduler: %s", exc)