INNER CODE UNIT · Python

health

flukelaster/ai-trading-agent · backend/app/main.py:495

async def health():
    mgr = app.state.manager
    first_engine = next(iter(mgr.engines.values())) if mgr.engines else None
    payload = await check_health(
        first_engine,
        app.state.connector,
        app.state.redis,
        app.state.ai_client,
    )
    # Return 503 when degraded so platform liveness probes (Railway, k8s) can
    # actually evict / restart the pod. Plain 200 every time gave probes
    # nothing to act on, hiding outages.
    if payload.get("status") != "ok":
        from fastapi.responses import JSONResponse

        return JSONResponse(payload, status_code=503)
    return payload

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…