25 lines
559 B
Python
25 lines
559 B
Python
"""Health check endpoint."""
|
|
|
|
from fastapi import APIRouter
|
|
from spore_node.db.connection import get_pool
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
|
|
@router.get("/health")
|
|
async def health():
|
|
"""Node health check with DB connectivity."""
|
|
db_ok = False
|
|
try:
|
|
pool = get_pool()
|
|
async with pool.acquire() as conn:
|
|
await conn.fetchval("SELECT 1")
|
|
db_ok = True
|
|
except Exception:
|
|
pass
|
|
|
|
return {
|
|
"status": "ok" if db_ok else "degraded",
|
|
"db": "connected" if db_ok else "disconnected",
|
|
}
|