dsh-qianchuan-toolkit 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 1.0.13
|
|
4
|
+
|
|
5
|
+
- **再修看门狗误报(整点播报导致的)**:心跳里的 `nextAt` 可能是「醒来发整点播报」的时刻(00:00),发完播报后进程继续睡到 00:15,但心跳没更新 → 看门狗在 00:03 判 `heartbeat-stale` 误报。两处修:① 看门狗改为**优先看 `nextRound`**(真正的下一轮时间),只有没有 `nextRound` 时才退回 `nextAt`;② `hourly.mjs` 发完整点播报后立即重写心跳(`nextAt = nextRound = 下一轮`)。
|
|
6
|
+
- 验证:`{"ok":true}`;模拟 `nextRound` 已过 → 正常报 `heartbeat-stale`。
|
|
7
|
+
|
|
8
|
+
## 1.0.12
|
|
9
|
+
|
|
10
|
+
- **修看门狗误报(关键)**:原判据「心跳超过 6 分钟没更新 = 卡死」在正常节奏下必然误报 —— 巡航两轮之间最长 15 分钟(节点 :15/:30/:45/:55),每两轮之间都会报一次「🚨 巡航可能卡住」。现改为**只看心跳里自己写的下一轮时间**:`now > nextAt + 宽限`(默认 3 分钟,`--grace-min` 可调)才判卡死;没有 `nextAt` 时才退回按 `--stale-min` 判。告警文案也改成「已过下一轮时间 N 分钟仍未出现新心跳」。
|
|
11
|
+
- 验证:心跳 `nextAt` 在未来 → `{"ok":true}`;`nextAt` 已过 15 分钟 → 正常报 `heartbeat-stale`。
|
|
12
|
+
|
|
3
13
|
## 1.0.11
|
|
4
14
|
|
|
5
15
|
- **看门狗(watchdog.mjs,新)**:独立进程,每 60 秒查三件事 —— ① 心跳文件 `heartbeat.json` 是否新鲜(超过 6 分钟没更新 / 超过 `nextAt` 判定卡死);② `supervisor.pid` / `watch.pid` 是否还活着;③ CDP 9222 是否连得上。发现问题立即推 **QQ + 企业微信**(同一故障 30 分钟内只推一次),能把守夜进程拉起来就自动拉起,恢复后再推一条「已恢复」。窗口外不检查、不打扰。
|
|
@@ -755,6 +755,8 @@ try {
|
|
|
755
755
|
log('整点播报:等到 ' + new Date(due).toLocaleString('zh-CN'))
|
|
756
756
|
await sleep(Math.max(0, due - Date.now()))
|
|
757
757
|
await flushDueDigests()
|
|
758
|
+
// 播报发完后把心跳改回「下一轮」时间,避免看门狗把这次醒来误判成卡死
|
|
759
|
+
if (next) writeHeartbeat({ round: i, ms: Date.now() - roundStart, nextAt: next, nextRound: next })
|
|
758
760
|
}
|
|
759
761
|
}
|
|
760
762
|
if (last) break
|
|
@@ -33,6 +33,7 @@ const END = arg('end', '01:00')
|
|
|
33
33
|
const ONCE = has('once')
|
|
34
34
|
const INTERVAL = Math.max(20, Number(arg('interval', '60'))) * 1000
|
|
35
35
|
const STALE_MS = Math.max(2, Number(arg('stale-min', '6'))) * 60000
|
|
36
|
+
const GRACE_MS = Math.max(0, Number(arg('grace-min', '3'))) * 60000
|
|
36
37
|
const ALERT_WIN = 30 * 60000
|
|
37
38
|
|
|
38
39
|
const log = (...a) => console.log(new Date().toLocaleString('zh-CN'), ...a)
|
|
@@ -101,10 +102,14 @@ async function check() {
|
|
|
101
102
|
|
|
102
103
|
if (!hb) issues.push({ kind: 'no-heartbeat', msg: '还没有心跳文件(巡航可能从未成功跑过一轮)' })
|
|
103
104
|
else {
|
|
105
|
+
// 关键:巡航两轮之间最长 15 分钟,所以「多久没更新」不能当成卡死依据。
|
|
106
|
+
// 只有「已经过了它自己说的下一轮时间 + 宽限」才算卡死。
|
|
104
107
|
const hbMs = new Date(hb.ts).getTime()
|
|
105
108
|
const age = now - hbMs
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
// 优先用 nextRound(真正的下一轮);nextAt 可能只是「醒来发整点播报」的时刻,会正常过期
|
|
110
|
+
const dueAt = Number(hb.nextRound || 0) || Number(hb.nextAt || 0) || 0
|
|
111
|
+
const overdue = dueAt ? now > dueAt + GRACE_MS : age > STALE_MS
|
|
112
|
+
if (overdue) issues.push({ kind: 'heartbeat-stale', msg: (dueAt ? '已过下一轮时间 ' + Math.round((now - dueAt) / 60000) + ' 分钟仍未出现新心跳' : '心跳停止 ' + Math.round(age / 60000) + ' 分钟') + '(最后 ' + new Date(hb.ts).toLocaleString('zh-CN') + ',第 ' + (hb.round || '?') + ' 轮' + (dueAt ? ',应于 ' + new Date(dueAt).toLocaleString('zh-CN') + ' 有新心跳' : '') + ')' })
|
|
108
113
|
}
|
|
109
114
|
if (!alive(supPid)) issues.push({ kind: 'supervisor-dead', msg: '守夜进程不存在(supervisor.pid=' + (supPid || '无') + ')' })
|
|
110
115
|
if (!alive(watchPid) && inWindow(now)) issues.push({ kind: 'watch-dead', msg: '巡航进程不存在(watch.pid=' + (watchPid || '无') + ')' })
|