修复健康监控

This commit is contained in:
2026-04-01 16:37:23 +08:00
parent c4ad386b9f
commit c0cfc4ba9f

View File

@@ -25,6 +25,7 @@ from .routers.v1 import (
auth_router, user_router, todos_router, auth_router, user_router, todos_router,
notes_router, tools_router, stats_router notes_router, tools_router, stats_router
) )
from sqlalchemy import text
@asynccontextmanager @asynccontextmanager
@@ -90,7 +91,8 @@ app.middleware("http")(log_requests)
@app.get("/health") @app.get("/health")
async def health_check(db: Session = Depends(get_db)): async def health_check(db: Session = Depends(get_db)):
try: try:
db.execute("SELECT 1") # 使用 text() 包裹 SQL 语句
db.execute(text("SELECT 1"))
return { return {
"status": "healthy", "status": "healthy",
"database": "connected", "database": "connected",