build: harden controller v2 runtime

This commit is contained in:
Media
2026-08-06 19:23:02 -05:00
parent 4e185b2e1c
commit 63ea314b18
15 changed files with 818 additions and 103 deletions
+11 -6
View File
@@ -2,10 +2,13 @@
from __future__ import annotations
import os
import sys
from controller.config import load_config
bind = f"0.0.0.0:{int(os.environ.get('PORT', '7531'))}"
_web_config = load_config().web
bind = f"{_web_config.host}:{_web_config.port}"
workers = 1
worker_class = "gthread"
threads = 4
@@ -14,12 +17,14 @@ accesslog = "-"
errorlog = "-"
capture_output = True
timeout = 30
graceful_timeout = 15
graceful_timeout = 30
worker_tmp_dir = "/tmp"
control_socket_disable = True
def worker_exit(server, worker): # pragma: no cover - exercised by Gunicorn
try:
from wsgi import service
except Exception:
module = sys.modules.get("wsgi")
service = getattr(module, "service", None)
if service is None:
return
service.stop()