17 lines
553 B
Python
17 lines
553 B
Python
"""系统健康检查:四库就绪状态 + 各库探测耗时(任一失败返回 503 + 明细)。"""
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from config.database import check_ready_detail
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health/ready")
|
|
async def health_ready():
|
|
dbs = await check_ready_detail()
|
|
all_ok = all(v["status"] == "ok" for v in dbs.values())
|
|
return JSONResponse(
|
|
status_code=200 if all_ok else 503,
|
|
content={"status": "ready" if all_ok else "degraded", "dbs": dbs},
|
|
) |