Fix health check endpoint for proper monitoring
This commit is contained in:
parent
f01c89550c
commit
0e43d38997
@ -1,15 +1,11 @@
|
|||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter
|
||||||
from sqlalchemy.orm import Session
|
|
||||||
|
|
||||||
from app.db.session import get_db
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@router.get("", summary="Health check endpoint")
|
@router.get("", summary="Health check endpoint")
|
||||||
def health_check(db: Session = Depends(get_db)):
|
def health_check():
|
||||||
"""
|
"""
|
||||||
Health check endpoint that verifies the application is running
|
Health check endpoint that verifies the application is running
|
||||||
and database connection is working
|
|
||||||
"""
|
"""
|
||||||
return {"status": "ok", "message": "Todo API is running"}
|
return {"status": "ok", "message": "Todo API is running"}
|
9
main.py
9
main.py
@ -23,6 +23,15 @@ if settings.BACKEND_CORS_ORIGINS:
|
|||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Root-level health check endpoint
|
||||||
|
@app.get("/health", tags=["health"])
|
||||||
|
async def root_health_check():
|
||||||
|
"""
|
||||||
|
Root-level health check endpoint that verifies the application is running.
|
||||||
|
This endpoint is used by monitoring systems to check if the service is alive.
|
||||||
|
"""
|
||||||
|
return {"status": "ok", "message": "Todo API is running"}
|
||||||
|
|
||||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user