From 9562fdaf6b12428a7e85579d154c3a9ecd668dcc Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sun, 12 Jul 2026 09:07:47 +0200 Subject: [PATCH] =?UTF-8?q?fix(backend):=20cap=20graceful=20shutdown=20at?= =?UTF-8?q?=203s=20=E2=80=94=20the=20charger's=20ever-open=20WebSocket=20m?= =?UTF-8?q?ade=20Ctrl+C=20hang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit uvicorn waits for connections to drain on SIGINT; the JC-6620 never hangs up, so shutdown blocked until a second (force) Ctrl+C. timeout_graceful_shutdown=3 closes the socket and exits; the charger redials within seconds. --- backend/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/main.py b/backend/main.py index d6f743d..ac1cf95 100644 --- a/backend/main.py +++ b/backend/main.py @@ -76,8 +76,12 @@ async def main(): "NO USERS CONFIGURED — the API is OPEN (anonymous admin). " "Create one: venv\\Scripts\\python -m backend.users add --scopes admin" ) + # timeout_graceful_shutdown: the charger holds its WebSocket open FOREVER, + # so a graceful "wait for connections to drain" would hang Ctrl+C — cap it. + # The charger reconnects within seconds after a restart anyway. await uvicorn.Server( - uvicorn.Config(app, host="0.0.0.0", port=9000, log_config=None) + uvicorn.Config(app, host="0.0.0.0", port=9000, log_config=None, + timeout_graceful_shutdown=3) ).serve()