Skip to content

Commit

Permalink
Try fix the health endpoint
Browse files Browse the repository at this point in the history
CharlyJazz committed Nov 19, 2023
1 parent b515da5 commit 00ace89
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion auth-microservice/app/api/health.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from starlette.responses import Response
from sqlalchemy.sql import text

from app.api.deps import get_session

@@ -13,7 +14,7 @@
@router.get("/", status_code=200)
async def health(session: AsyncSession = Depends(get_session)):
try:
await asyncio.wait_for(session.execute("SELECT 1"), timeout=1)
await asyncio.wait_for(session.execute(text("SELECT 1")), timeout=1)
except (asyncio.TimeoutError, socket.gaierror):
return Response(status_code=503)
return Response(status_code=200)

0 comments on commit 00ace89

Please sign in to comment.