fix: 修复 /api/health 404 和扫描/发现 500 错误

1. /api/health 404: 前端 fetchVersion 调用 /api/health,但后端只有 /health。
   OpenResty 保留完整路径,需要在后端添加 /api/health 端点。

2. 扫描/发现 500: check_service.py 的连接池 _get_cached_ssh 缓存了
   SSH 连接,但调用方在 finally 中 ssh.close() 关闭连接。第二次调用
   从缓存拿到已关闭的连接导致执行失败。改为异常时清除缓存、正常时
   保留连接(5分钟TTL自动管理生命周期)。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-12 11:15:01 +08:00
parent 3ee8846011
commit 0bab72ea98
2 changed files with 16 additions and 6 deletions
+6
View File
@@ -112,3 +112,9 @@ def health_check():
status["db"] = "error"
status["status"] = "degraded"
return status
@app.get("/api/health")
def api_health_check():
"""API 路径下的健康检查(用于前端通过 /api/ 代理访问)"""
return health_check()