41 lines
1.7 KiB
Markdown
41 lines
1.7 KiB
Markdown
|
|
# Changelog — Layer 3 宿主机巡检完美实现
|
||
|
|
|
||
|
|
**日期**: 2026-06-07
|
||
|
|
|
||
|
|
## 摘要
|
||
|
|
|
||
|
|
打通设置页 Telegram 配置与 Layer-3 宿主机巡检(`health_monitor.sh` + cron):保存时自动同步 `.env`、脚本支持从 MySQL 回退读取、设置页展示巡检状态与手动同步、部署时自动安装 cron。
|
||
|
|
|
||
|
|
## 动机
|
||
|
|
|
||
|
|
用户在设置页配置 Telegram 后,应用内告警与测试发送可用,但宿主机 cron 巡检仅读 `docker/.env.prod` / 容器 `/app/.env`,导致 Layer-3 重启告警 Telegram 可能静默失败。
|
||
|
|
|
||
|
|
## 涉及文件
|
||
|
|
|
||
|
|
| 文件 | 变更 |
|
||
|
|
|------|------|
|
||
|
|
| `server/infrastructure/env_file.py` | 新增 `.env` upsert/read 工具 |
|
||
|
|
| `server/application/services/ops_patrol_sync.py` | Telegram → `/app/.env`、persist 卷、host `.env.prod` |
|
||
|
|
| `server/api/settings.py` | `set_setting` 钩子;`GET/POST ops-patrol/*` |
|
||
|
|
| `deploy/health_monitor.sh` | `load_telegram_from_db` MySQL 回退 |
|
||
|
|
| `deploy/deploy-production.sh` | 部署成功时自动 `install_ops_cron.sh` |
|
||
|
|
| `deploy/nexus-1panel.sh` | `sync_env_prod_to_volume` 含 Telegram 键 |
|
||
|
|
| `frontend/src/pages/SettingsPage.vue` | Layer 3 巡检状态与同步 UI |
|
||
|
|
| `frontend/src/types/api.ts` | OpsPatrol 类型 |
|
||
|
|
| `tests/test_ops_patrol_sync.py` | 单元测试 |
|
||
|
|
|
||
|
|
## 迁移 / 重启
|
||
|
|
|
||
|
|
- 无需 DB 迁移
|
||
|
|
- 后端需重启/重新部署容器;前端需 vite build
|
||
|
|
- 生产需确保 cron 已安装(部署脚本现自动尝试)
|
||
|
|
|
||
|
|
## 验证方式
|
||
|
|
|
||
|
|
```bash
|
||
|
|
pytest tests/test_ops_patrol_sync.py -q
|
||
|
|
bash scripts/local_verify.sh
|
||
|
|
# 设置页保存 Telegram → 刷新 Layer 3 状态 → 「同步巡检 Telegram」
|
||
|
|
# 生产: crontab -l | grep nexus-health-monitor; tail /var/log/nexus_health.log
|
||
|
|
```
|