26 lines
725 B
Python
26 lines
725 B
Python
from typing import Any
|
|
|
|
from fastapi import APIRouter, Response, status
|
|
|
|
from app.service.health_service import HealthService
|
|
|
|
router = APIRouter(prefix="/internal", tags=["operations"])
|
|
|
|
|
|
@router.get("/health/live")
|
|
async def live() -> dict[str, str]:
|
|
return {"status": "ok"}
|
|
|
|
|
|
@router.get("/health/ready")
|
|
async def ready(response: Response) -> dict[str, Any]:
|
|
result = await HealthService().ready()
|
|
response.status_code = (status.HTTP_200_OK if result["status"] == "ready"
|
|
else status.HTTP_503_SERVICE_UNAVAILABLE)
|
|
return result
|
|
|
|
|
|
@router.get("/metrics")
|
|
async def metrics() -> Response:
|
|
return Response("# TYPE jr_agent_up gauge\njr_agent_up 1\n", media_type="text/plain")
|