feat: implement background scheduler for job scraping with Gunicorn support
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user