feat: enforce single-worker at startup

Fail with RuntimeError when WEB_CONCURRENCY or BANGUI_WORKERS > 1.

In-memory session cache, rate-limit windows, and runtime state are
process-local. Multi-worker silently causes stale limits, ghost sessions,
inconsistent status.

Skipped when TESTING=1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-05-03 20:33:23 +02:00
parent e1a6491ac2
commit ae9313568e
5 changed files with 919 additions and 10 deletions

View File

@@ -30,7 +30,7 @@ SINGLE-WORKER ENFORCEMENT:
2. Database lock: Only one instance can run the scheduler at a time
3. Startup validation: Fails loudly if multi-worker scenario is detected
See Docs/Architekture.md § Deployment Constraints for full details.
See Docs/Deployment.md § Single-Worker Requirement for full details.
MULTI-WORKER SOLUTION (Future):
To deploy BanGUI with multiple workers in the future (e.g., via gunicorn -w 4):