22 lines
718 B
Python
22 lines
718 B
Python
from fastapi import APIRouter, Request
|
|
|
|
from app.core.database import check_database
|
|
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")
|
|
def readiness(request: Request) -> Health:
|
|
# Готовность = приложение может обслужить синхронный путь, а он требует БД.
|
|
if not check_database(request.app.state.engine):
|
|
raise unavailable()
|
|
return Health(status="ok")
|