"""Gunicorn config for the mail web app. Single process, many threads — SSE/IDLE state is in-process, so multi-worker would multiply IMAP IDLE connections per user. Threading model is enough for ~50 concurrent users on this host. """ import os bind = f"0.0.0.0:{os.getenv('FLASK_PORT', '5000')}" workers = int(os.getenv("GUNICORN_WORKERS", "1")) # gevent: cooperative greenlets, тысячи одновременных SSE без thread-pool boundaries. # Monkey-patch выставлен в wsgi.py до всех импортов. worker_class = os.getenv("GUNICORN_WORKER_CLASS", "gevent") worker_connections = int(os.getenv("GUNICORN_CONNECTIONS", "2000")) threads = int(os.getenv("GUNICORN_THREADS", "1")) # для gevent threads не нужны timeout = 0 # SSE-стримы могут жить долго; greenlets сами уступают graceful_timeout = 10 keepalive = 65 preload_app = False # gevent не любит preload + os.fork accesslog = "-" errorlog = "-" loglevel = os.getenv("GUNICORN_LOGLEVEL", "info")