"""Gunicorn configuration. All Gunicorn settings live here instead of the Dockerfile CMD so they can be tweaked without rebuilding the image, and so the access-log format/timezone are defined in one place. """ import os import time # ---- Server ---- bind = "0.0.0.0:8000" workers = 2 # ---- Logging ---- accesslog = "-" errorlog = "-" capture_output = True loglevel = "info" # %(h)s = real client IP. Gunicorn resolves X-Forwarded-For based on its built-in # proxy trust logic (the same mechanism already validated behind Traefik). # %(t)s = overridden by CustomLogger -> [2026-08-09 20:41:00 +0300] access_log_format = '%(h)s - - [%(t)s] "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' logger_class = "gunicorn_logger:CustomLogger" # ---- Timezone for Python logging / error logs ---- # Default to UTC unless TZ is set (e.g. TZ=Africa/Nairobi at docker run time). os.environ.setdefault("TZ", os.environ.get("TZ", "UTC")) try: time.tzset() except AttributeError: # non-Unix pass