Files
mtusi2026lab3/src/messenger/gunicorn_conf.py
T
ArtyomandClaude Opus 5.5 416ce4f9db Carry over the lab 2 solution
Bring the application, own tests, Dockerfile, toolchain, compose
stack, migrations, secret generator, restart hook, evidence scripts and
CI job from the lab 2 solution commit 8cddb09 unchanged, merge the lab
2 Makefile targets into the lab 3 skeleton Makefile without touching
its targets, and append the lab 2 solution variables to the skeleton
.env.example. The package version follows the contract version 1.3.0.

This is the starting point of the lab 3 cycle: lint, own tests and the
offline skeleton check pass before any lab 3 change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-28 11:26:15 +03:00

42 lines
1.3 KiB
Python

import os
from typing import Any
from gunicorn.glogging import Logger as GunicornBaseLogger
from uvicorn_worker import UvicornWorker
from messenger.main import LOG_FIELDS
from messenger.shared.infrastructure.logging import configure
LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO")
class StructlogGunicornLogger(GunicornBaseLogger):
def setup(self, cfg: object) -> None:
configure(LOG_LEVEL, LOG_FIELDS)
def access(self, resp: object, req: object, environ: object, request_time: object) -> None:
return
class MessengerWorker(UvicornWorker):
CONFIG_KWARGS: dict[str, Any] = {
"access_log": False,
"server_header": False,
"date_header": False,
"timeout_graceful_shutdown": int(os.environ.get("SHUTDOWN_TIMEOUT_SECONDS", "10")),
}
bind = f"{os.environ.get('HOST', '0.0.0.0')}:{os.environ.get('PORT', '8080')}"
workers = int(os.environ.get("WEB_CONCURRENCY", "4"))
worker_class = "messenger.gunicorn_conf.MessengerWorker"
logger_class = StructlogGunicornLogger
loglevel = LOG_LEVEL.lower()
accesslog = None
errorlog = "-"
timeout = int(float(os.environ.get("REQUEST_TIMEOUT_SECONDS", "15")) + 5)
graceful_timeout = int(os.environ.get("SHUTDOWN_TIMEOUT_SECONDS", "10"))
keepalive = 5
preload_app = False
control_socket_disable = True