From fcf13b91fa10480f3b42c719e85312912736fd1e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 30 Dec 2025 20:41:20 +0000 Subject: [PATCH] Fix health check: return 200 when server running, include API status in body --- server.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/server.py b/server.py index 0f5d41b..c34b366 100644 --- a/server.py +++ b/server.py @@ -520,20 +520,23 @@ def get_api_reference() -> str: # --- Health Check Endpoint --- async def health(request): - """Health check endpoint for Docker/load balancer.""" - if not OUTLINE_API_URL or not OUTLINE_API_TOKEN: - return JSONResponse( - { - "status": "degraded", - "error": "Missing OUTLINE_API_URL or OUTLINE_API_TOKEN", - }, - status_code=503, - ) + """Health check endpoint for Docker/load balancer. - healthy, message = await outline_client.check_health() - if healthy: - return JSONResponse({"status": "ok"}) - return JSONResponse({"status": "degraded", "error": message}, status_code=503) + Returns 200 if server is running. API connectivity status is included + in response body but doesn't affect HTTP status code. + """ + response = {"status": "ok", "server": "running"} + + if not OUTLINE_API_URL or not OUTLINE_API_TOKEN: + response["api"] = "not_configured" + response["detail"] = "Missing OUTLINE_API_URL or OUTLINE_API_TOKEN" + else: + healthy, message = await outline_client.check_health() + response["api"] = "connected" if healthy else "disconnected" + if not healthy: + response["detail"] = message + + return JSONResponse(response) # --- ASGI Application ---