| import os | |
| # General recommendation: (2 * number_of_cores) + 1 | |
| # For your 2vCPU machine, 5 is a good starting point. | |
| workers = int(os.environ.get('GUNICORN_PROCESSES', '5')) | |
| # Use the Uvicorn worker class for asyncio compatibility | |
| worker_class = "uvicorn.workers.UvicornWorker" | |
| # The address and port to bind to | |
| bind = "0.0.0.0:8000" | |
| # Set log levels | |
| loglevel = "info" | |
| accesslog = "-" # Log access to stdout | |
| errorlog = "-" # Log errors to stderr | |
| # --- CRUCIAL CHANGE --- | |
| # Set worker timeout to 0 to disable it completely. | |
| # This prevents Gunicorn from killing workers during long-running streams. | |
| timeout = 0 | |
| # Timeout for gracefully restarting a worker (still useful for deployments) | |
| graceful_timeout = 60 |