"""Gunicorn configuration for Command Sovereignty (production).
Run with:
gunicorn -c gunicorn.conf.py wsgi:app
"""
import multiprocessing # noqa: F401 (kept for easy tuning)
# Binding — nginx (or other reverse proxy) fronts this on localhost only
bind = "127.0.0.1:5003"
# Worker model: 2 processes x 4 threads (gthread) suits SQLite —
# limits write concurrency while still handling parallel requests.
workers = 2
threads = 4
worker_class = "gthread"
# Do NOT preload: each worker gets its own SQLite connections / app state.
preload_app = False
# Timeouts
timeout = 60
graceful_timeout = 30
keepalive = 5
# Recycle workers periodically to bound memory growth
max_requests = 1000
max_requests_jitter = 100
# Logging — systemd journal captures stdout/stderr
accesslog = "-"
errorlog = "-"
loglevel = "info"
access_log_format = '%(h)s "%(r)s" %(s)s %(b)s %(L)ss'
# Process naming
proc_name = "command-sovereignty"