23 lines
621 B
Python
23 lines
621 B
Python
from fastapi import APIRouter, Request
|
|
|
|
from app.core.database import check_database
|
|
from app.core.redis import check_redis
|
|
from app.errors.exceptions import unavailable
|
|
from app.schemas.base import Health
|
|
|
|
router = APIRouter(prefix="/health", tags=["health"])
|
|
|
|
|
|
@router.get("/live")
|
|
async def liveness() -> Health:
|
|
return Health(status="ok")
|
|
|
|
|
|
@router.get("/ready")
|
|
async def readiness(request: Request) -> Health:
|
|
if not await check_database(request.app.state.engine):
|
|
raise unavailable()
|
|
if not await check_redis(request.app.state.redis):
|
|
raise unavailable()
|
|
return Health(status="ok")
|