39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
"""
|
|
gunicorn.conf.py — Gunicorn configuration for VideoPress.
|
|
|
|
Key choices:
|
|
worker_class = gevent
|
|
Gevent workers are required for Server-Sent Events (SSE). A standard
|
|
sync worker would block on the SSE generator and starve other requests.
|
|
Gevent patches blocking I/O so each SSE stream is handled as a
|
|
lightweight greenlet, not a full OS thread.
|
|
|
|
workers = 1
|
|
FFmpeg compression jobs are stored in an in-process dict (active_jobs).
|
|
Multiple worker *processes* would not share that state. Keep workers=1
|
|
and let gevent's concurrency handle multiple simultaneous HTTP clients.
|
|
If you need multi-process resilience, replace the in-process job store
|
|
with Redis or a database.
|
|
|
|
timeout = 0
|
|
SSE streams are long-lived; the default 30-second worker timeout would
|
|
kill them. Setting timeout=0 disables the timeout entirely for gevent
|
|
workers (gevent uses its own internal greenlet scheduling).
|
|
"""
|
|
|
|
import os
|
|
|
|
bind = f"0.0.0.0:{os.environ.get('PORT', '8080')}"
|
|
workers = 1 # see note above — must stay at 1
|
|
worker_class = 'gevent'
|
|
worker_connections = 100 # max simultaneous greenlets per worker
|
|
timeout = 0 # disable worker timeout for SSE streams
|
|
keepalive = 5
|
|
loglevel = os.environ.get('LOG_LEVEL', 'info')
|
|
accesslog = '-' # stdout
|
|
errorlog = '-' # stderr
|
|
capture_output = True
|
|
|
|
# Forward the real client IP when behind a reverse proxy (nginx / Traefik)
|
|
forwarded_allow_ips = '*'
|
|
proxy_allow_ips = '*'
|