From a17f291850855a2699a752e60f529812310edb9d Mon Sep 17 00:00:00 2001 From: claude_dev Date: Sat, 1 Aug 2026 21:01:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E5=8A=A0=20/health=20=E5=AD=98?= =?UTF-8?q?=E6=B4=BB=E6=8E=A2=E9=92=88=E7=AB=AF=E7=82=B9(=E6=B2=BBDocker?= =?UTF-8?q?=20HEALTHCHECK=E6=81=92unhealthy,/health=E5=8E=9F404)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sanguo_api/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sanguo_api/main.py b/sanguo_api/main.py index 75a5129..047294f 100644 --- a/sanguo_api/main.py +++ b/sanguo_api/main.py @@ -61,6 +61,12 @@ def build_app(config_path: str = "config/backtest.yaml", static_dir: str | None max_workers=max_workers, ) + # Liveness probe for Docker HEALTHCHECK (curl -f /health). Registered + # unconditionally so it works with or without the SPA static mount. + @app.get("/health", include_in_schema=False) + async def _health() -> dict[str, str]: + return {"status": "ok"} + # SPA static mount with history fallback. Register the root route BEFORE # mounting StaticFiles at "/" so the explicit handler wins for "/". if static_dir and os.path.isdir(static_dir):