# gunicorn.conf.py -- production WSGI config for marker-api import os import multiprocessing port = int(os.environ.get("PORT", "8000")) workers = min(multiprocessing.cpu_count() * 2 + 1, 8) bind = f"0.0.0.0:{port}" workers = int(os.environ.get("GUNICORN_WORKERS", "1")) workers = min(workers, 8) worker_class = "gthread" threads = int(os.environ.get("GUNICORN_THREADS", "4")) timeout = int(os.environ.get("GUNICORN_TIMEOUT", "300")) graceful_timeout = 60 accesslog = "-" errorlog = "-" loglevel = os.environ.get("GUNICORN_LOGLEVEL", "info") # Preload so models are loaded once in master process (not duplicated per-worker) preload_app = True # Enable worker recycling to prevent memory leaks max_requests = 1000 max_requests_jitter = 100 # Tempdir for marker uploads tempdir = "/app/uploads"