33 lines
817 B
Python
33 lines
817 B
Python
"""ARQ worker entry point."""
|
|
|
|
import logging
|
|
from urllib.parse import urlparse
|
|
|
|
from arq.connections import RedisSettings
|
|
|
|
from app.config import settings
|
|
from app.workers.tasks import process_job, render_clip
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
)
|
|
|
|
|
|
def _redis_settings() -> RedisSettings:
|
|
parsed = urlparse(settings.redis_url)
|
|
return RedisSettings(
|
|
host=parsed.hostname or "redis",
|
|
port=parsed.port or 6379,
|
|
database=int(parsed.path.lstrip("/") or "0"),
|
|
)
|
|
|
|
|
|
class WorkerSettings:
|
|
functions = [process_job, render_clip]
|
|
redis_settings = _redis_settings()
|
|
max_jobs = settings.max_concurrent_jobs
|
|
job_timeout = 3600 # 1 hour max per job
|
|
keep_result = 3600
|
|
health_check_interval = 30
|