dsh-qianchuan-toolkit 1.0.11 → 1.0.12

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,10 @@
1
1
  # 更新日志
2
2
 
3
+ ## 1.0.12
4
+
5
+ - **修看门狗误报(关键)**:原判据「心跳超过 6 分钟没更新 = 卡死」在正常节奏下必然误报 —— 巡航两轮之间最长 15 分钟(节点 :15/:30/:45/:55),每两轮之间都会报一次「🚨 巡航可能卡住」。现改为**只看心跳里自己写的下一轮时间**:`now > nextAt + 宽限`(默认 3 分钟,`--grace-min` 可调)才判卡死;没有 `nextAt` 时才退回按 `--stale-min` 判。告警文案也改成「已过下一轮时间 N 分钟仍未出现新心跳」。
6
+ - 验证:心跳 `nextAt` 在未来 → `{"ok":true}`;`nextAt` 已过 15 分钟 → 正常报 `heartbeat-stale`。
7
+
3
8
  ## 1.0.11
4
9
 
5
10
  - **看门狗(watchdog.mjs,新)**:独立进程,每 60 秒查三件事 —— ① 心跳文件 `heartbeat.json` 是否新鲜(超过 6 分钟没更新 / 超过 `nextAt` 判定卡死);② `supervisor.pid` / `watch.pid` 是否还活着;③ CDP 9222 是否连得上。发现问题立即推 **QQ + 企业微信**(同一故障 30 分钟内只推一次),能把守夜进程拉起来就自动拉起,恢复后再推一条「已恢复」。窗口外不检查、不打扰。
@@ -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,13 @@ 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
- const overdue = hb.nextAt && now > Number(hb.nextAt) + STALE_MS
107
- if (age > STALE_MS || overdue) issues.push({ kind: 'heartbeat-stale', msg: '心跳停止 ' + Math.round(age / 60000) + ' 分钟(最后 ' + new Date(hb.ts).toLocaleString('zh-CN') + ',第 ' + (hb.round || '?') + ' 轮' + (hb.nextAt ? ',应于 ' + new Date(hb.nextAt).toLocaleString('zh-CN') + ' 有新心跳' : '') + ')' })
109
+ const dueAt = Number(hb.nextAt || 0) || Number(hb.nextRound || 0) || 0
110
+ const overdue = dueAt ? now > dueAt + GRACE_MS : age > STALE_MS
111
+ 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
112
  }
109
113
  if (!alive(supPid)) issues.push({ kind: 'supervisor-dead', msg: '守夜进程不存在(supervisor.pid=' + (supPid || '无') + ')' })
110
114
  if (!alive(watchPid) && inWindow(now)) issues.push({ kind: 'watch-dead', msg: '巡航进程不存在(watch.pid=' + (watchPid || '无') + ')' })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-qianchuan-toolkit",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "description": "DSH skill bundle for 巨量千川: 直播盯盘自动控量 (qianchuan-live-control) + 乘方计划复制 (qianchuan-plan-copy).",
6
6
  "license": "MIT",