Fix health check: return 200 when server running, include API status in body
All checks were successful
Build and Push Outline MCP Docker Image / build (push) Successful in 6s
All checks were successful
Build and Push Outline MCP Docker Image / build (push) Successful in 6s
This commit is contained in:
29
server.py
29
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 ---
|
||||
|
||||
Reference in New Issue
Block a user