diff --git a/deploy/gate_log.jsonl b/deploy/gate_log.jsonl index 285c1c7f..e32516b5 100644 --- a/deploy/gate_log.jsonl +++ b/deploy/gate_log.jsonl @@ -426,3 +426,13 @@ {"ts":"2026-06-07T20:17:03+08:00","date":"2026-06-07","gate":"shell_eol","result":"PASS","detail":"all tracked sh LF"} {"ts":"2026-06-07T20:17:03+08:00","date":"2026-06-07","gate":"text_eol","result":"PASS","detail":"git index LF"} {"ts":"2026-06-07T20:17:03+08:00","date":"2026-06-07","gate":"summary","result":"PASS","detail":"7/7"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"changelog","result":"PASS","detail":"2026-06-07-health-monitor-flock-fail-count-fix.md 21lines"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"audit","result":"PASS","detail":"2026-06-07-ops-patrol-layer3-telegram.md"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"test","result":"PASS","detail":"all passed"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"lint","result":"PASS","detail":"0 violations"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"import","result":"PASS","detail":"ok"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"security","result":"PASS","detail":"0 HIGH"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"review","result":"PASS","detail":"audit covers changes"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"shell_eol","result":"PASS","detail":"all tracked sh LF"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"text_eol","result":"PASS","detail":"git index LF"} +{"ts":"2026-06-07T20:53:00+08:00","date":"2026-06-07","gate":"summary","result":"PASS","detail":"7/7"} diff --git a/deploy/health_monitor.sh b/deploy/health_monitor.sh index 7cdb1bff..871236a5 100644 --- a/deploy/health_monitor.sh +++ b/deploy/health_monitor.sh @@ -106,6 +106,7 @@ bump_fail_count() { fail=$((fail + 1)) echo "$fail" > "$FAIL_FILE" ) 9>"${FAIL_FILE}.lock" + fail="$(cat "$FAIL_FILE" 2>/dev/null || echo 0)" else fail="$(cat "$FAIL_FILE" 2>/dev/null || echo 0)" fail=$((fail + 1)) diff --git a/docs/audit/2026-06-07-ops-patrol-layer3-telegram.md b/docs/audit/2026-06-07-ops-patrol-layer3-telegram.md index da513daf..ae135cb1 100644 --- a/docs/audit/2026-06-07-ops-patrol-layer3-telegram.md +++ b/docs/audit/2026-06-07-ops-patrol-layer3-telegram.md @@ -7,7 +7,7 @@ | `server/infrastructure/env_file.py` | `.env` upsert/read(UTF-8 LF) | | `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/health_monitor.sh` | `load_telegram_from_db` + `bump_fail_count` flock 修复 | | `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 | diff --git a/docs/changelog/2026-06-07-health-monitor-flock-fail-count-fix.md b/docs/changelog/2026-06-07-health-monitor-flock-fail-count-fix.md new file mode 100644 index 00000000..123a0ecb --- /dev/null +++ b/docs/changelog/2026-06-07-health-monitor-flock-fail-count-fix.md @@ -0,0 +1,21 @@ +# Changelog — health_monitor flock 失败计数修复 + +**日期**: 2026-06-07 + +## 摘要 + +修复 `bump_fail_count` 在使用 `flock` 时子 shell 未回传计数、导致 `FAIL` 恒为 0、Layer 3 永不触发重启/Telegram 的 bug。 + +## 动机 + +生产模拟巡检时发现连续 3 次 /health 失败后 `last_restart` 仍为空;`bash -x` 显示 `FAIL=0` 而 `/tmp/nexus_health_fail_count` 已为 3。 + +## 涉及文件 + +- `deploy/health_monitor.sh` + +## 验证 + +```bash +# 阻断 127.0.0.1:8600 后连续执行 3 次 health_monitor.sh,第 3 次应触发 Telegram + docker restart +```