Files
Nexus/docs/reports/2026-06-07-ops-patrol-deploy-verification.md
T
Nexus Agent e5a3f2524e fix(auth): change_password 改密路径 audit_repo 定义顺序
部署前补齐门控审计与 Layer3 演练终验记录,消除 ruff F821。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 23:11:28 +08:00

4.5 KiB
Raw Blame History

生产验证 — Layer 3 宿主机巡检 Telegram 打通

日期: 2026-06-07
Commit: f9934bd — feat(ops-patrol): Layer 3 巡检与 Telegram 配置打通
环境: https://api.synaglobal.vip

部署

结果
门控 7/7 PASS
push 66a4cba..f9934bd main → main
deploy-production ✓ Docker 重建,容器 healthy
远程版本 f9934bd

健康检查

检查 结果
GET /health ok
GET /app/ HTTP 200
外网 HTTPS HTTP 200

Layer 3 巡检

检查 结果
crontab nexus-health-monitor ✓ 已安装(部署脚本自动 install_ops_cron.sh
health_monitor.sh 手动执行 exit 0
/var/log/nexus_health.log 空(/health 正常,无告警写入)

Telegram / env 同步

检查 结果
DB telegram_bot_token 未配置
DB telegram_chat_id 未配置
/app/.env NEXUS_TELEGRAM_* 未写入
read_telegram_env_status() env_synced: false

说明: 生产尚未在设置页配置 Telegram;配置并保存后应自动 sync,或点「同步巡检 Telegram」。未 sync 时 health_monitor.sh 可通过 MySQL 回退(需 DB 有值)。

API

端点 未认证
GET /api/settings/ops-patrol/status 401(预期)

待用户终验

  1. 登录设置页 → 配置 Telegram → 确认 Layer 3 区块显示「巡检 Telegram 就绪」
  2. 点「同步巡检 Telegram」→ .env 已同步
  3. (可选)临时停容器验证 Telegram 重启告警

结论

部署成功cron 与 health_monitor 已就绪。Telegram 告警需用户在 UI 配置后终验。


用户配置后复查(2026-06-07

检查 结果
内存 TELEGRAM_BOT_TOKEN / CHAT_ID ✓ 已配置
容器 /app/.env NEXUS_TELEGRAM_* ✓ 已同步
read_telegram_env_status().env_synced true
宿主机 docker/.env.prod Telegram 未写入(容器无 host 写权限;不影响)
health_monitor 读取 Telegram READY via container .env
MySQL DB 回退 db_fallback_ok True
cron nexus-health-monitor ✓ 运行中

Layer 3 巡检 Telegram 闭环已就绪。 /health 连续失败时将能推送 Telegram 并自动重启。


模拟巡检告警(2026-06-07

发现与修复

说明
Bug bump_fail_countflock 子 shell 内递增,FAIL 恒为 0,永不触发重启/Telegram
Fix 764703d — 子 shell 写文件后 cat 回传计数
部署 已上线生产

演练(iptables 阻断 127.0.0.1:8600,容器保持运行)

步骤 结果
run1 / run2 fail=1 → fail=2
run3 fail=3last_restart 已写入,docker restart 执行
解除阻断后 /health ok,容器 Up (healthy)

Telegram:第 3 次失败应已推送「连续 3 次无响应 / 正在自动重启」及「已恢复」类消息(请用户在 Telegram 确认)。

用户确认(2026-06-07

  • ✓ 引号剥离修复后验证消息已收到
  • ✓ 中文详细通知(ea2507d)已收到

Layer 3 巡检 + Telegram 闭环终验通过。

注意

  • docker pause 不适合演练:docker exec 无法读 Telegram 配置
  • 演练方式:阻断宿主机 localhost 端口或真实进程故障(容器仍 Running)

二次演练(2026-06-07 15:06 UTC,用户请求)

步骤

  1. 重置 fail_count=0;冷却期已过(距上次重启 >7900s)
  2. iptables -I INPUT -i lo -p tcp --dport 8600 -j DROP(容器保持 Running
  3. 连续手动执行 health_monitor.sh ×3
  4. trap 解除 iptables;等待 8s 验证恢复

结果

检查 结果
run1 fail_count=1exit 0
run2 fail_count=3cron 并发 +1),触发重启
run3 fail_count=4exit 0
/tmp/nexus_health_last_restart 已更新(15:07 UTC
docker restart ✓ 容器 Up (healthy)
解除阻断后 /health local 200、HTTPS 200
iptables 残留 ✓ 已清除
fail_count 终态 0cleanup 重置)

Telegram(请用户在群组确认)

  • 🔴 「连续 3 次无响应 / 正在自动重启…」
  • 🟢 「Nexus 已自动恢复」(重启后 /health 通过)

用户确认(2026-06-07 续)

  • ✓ 二次演练 Telegram 两条消息均已收到

结论

Layer 3 巡检告警 + 自动重启 + 恢复通知 二次演练终验通过