Compare commits
1 Commits
main
...
078749a586
| Author | SHA1 | Date | |
|---|---|---|---|
| 078749a586 |
@@ -11,6 +11,7 @@ engine = create_async_engine(
|
|||||||
echo=False,
|
echo=False,
|
||||||
pool_size=10,
|
pool_size=10,
|
||||||
max_overflow=20,
|
max_overflow=20,
|
||||||
|
pool_timeout=30,
|
||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
pool_recycle=3600,
|
pool_recycle=3600,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
"""Health check and error metrics endpoints."""
|
"""Health check and error metrics endpoints."""
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
|
from sqlalchemy import text
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from cartsnitch_api.auth.dependencies import verify_service_key
|
from cartsnitch_api.auth.dependencies import verify_service_key
|
||||||
|
from cartsnitch_api.database import get_db
|
||||||
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
from cartsnitch_api.middleware.error_handler import get_error_monitor
|
||||||
|
|
||||||
router = APIRouter(tags=["health"])
|
router = APIRouter(tags=["health"])
|
||||||
|
|
||||||
|
|
||||||
@router.get("/health")
|
@router.get("/health")
|
||||||
async def health():
|
async def health(db: AsyncSession = Depends(get_db)):
|
||||||
return {"status": "ok"}
|
try:
|
||||||
|
await db.execute(text("SELECT 1"))
|
||||||
|
return {"status": "ok", "database": "connected"}
|
||||||
|
except Exception:
|
||||||
|
return {"status": "ok", "database": "disconnected"}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
@router.get("/internal/error-stats", dependencies=[Depends(verify_service_key)])
|
||||||
|
|||||||
Reference in New Issue
Block a user