feat: 添加 /health 健康检查端点

- 新增 GET /health 端点,公开无需认证
- 检查 PostgreSQL 数据库连接状态
- 健康时返回: {"status": "healthy", "database": "connected"}
- 不健康时返回 HTTP 503 + {"status": "unhealthy", "database": "disconnected", "error": "..."}
- 失败时记录错误到 JSON 日志
- 用于负载均衡器、Kubernetes、1Panel 健康探针
- 更新 IMPROVEMENTS.md 标记 6.3 完成
This commit is contained in:
2026-04-15 10:49:15 +08:00
parent 741d6acff1
commit 338871796a
2 changed files with 24 additions and 2 deletions

View File

@@ -201,7 +201,7 @@
- 完成时间2026-04-15
- 修改文件Cargo.toml, src/main.rs, src/config.rs
- [ ] **无日志聚合**
- [x] **无日志聚合**
- 需求:集中式日志管理
- 实现:配置日志收集器(如 ELK Stack
- 格式JSON 格式便于解析
@@ -224,10 +224,11 @@
- 工具Prometheus + Grafana
### 6.3 健康检查
- [ ] **缺少健康检查接口**
- [x] **缺少健康检查接口**
- 需求:负载均衡器健康检查
- 实现:添加 `/health` 端点
- 检查:数据库连接、服务状态
- 完成时间2026-04-15
## 七、部署改进