Skip to content

Commit

Permalink
return empty response instead of json
Browse files Browse the repository at this point in the history
  • Loading branch information
meln1k committed Apr 2, 2024
1 parent 4ff6231 commit e7f529e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fixbackend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,18 @@ async def health() -> Response:
try:
pong = await deps.readonly_redis.ping()
if not pong:
return JSONResponse(status_code=500, content="Redis health check failed")
log.error("Redis did not respond to ping")
return Response(status_code=500)

async with deps.session_maker() as session:
result = await session.execute(select(1))
if result.scalar_one() != 1:
return JSONResponse(status_code=500, content="MySQL health check failed")
log.error("MySQL did not return 1 from select 1")
return Response(status_code=500)

except Exception as e:
log.error("Health check failed", exc_info=e)
return JSONResponse(status_code=500, content="Health check failed")
return Response(status_code=500)

return Response(status_code=200)

Expand Down

0 comments on commit e7f529e

Please sign in to comment.