fix: 移除 inspectionSchedulerApi.start 中每次都触发 scanAllNow 的重复巡检
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
根因:renderer 多个页面(MonitoringPage、ReportPage、useReportAutoScheduler) mount 时各自调一次 inspectionSchedulerApi.start() 同步 hostConfigs。主进程 start handler 里 scheduler 已在运行时每次都 setImmediate(() => scanAllNow()), 导致短时间内同一批设备被巡检 N 次。 修复:去掉 scanAllNow 立即触发。start 只负责同步 hostConfigs。 InspectionScheduler 自身 30s tick 会按设备 effective_interval 正常调度。
This commit is contained in:
@@ -2018,19 +2018,15 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
_scheduler._hostInfo = hostInfo;
|
||||
console.log("[Inspection] 更新 hostConfigs:", Object.keys(_hostConfigs || {}).length, "台设备");
|
||||
}
|
||||
// start() 幂等:已 running 时直接返回;这里调 scanAllNow 让新 hostConfigs 立即生效,
|
||||
// 不用等下一个 30 秒 tick
|
||||
// start() 幂等:已 running 时直接返回。
|
||||
// 不再每次 start 都 scanAllNow —— renderer 可能在多个页面 mount 时反复调 start
|
||||
// (MonitoringPage、ReportPage、useReportAutoScheduler 各调一次),每次都 scanAllNow
|
||||
// 会导致短时间内同一批设备被巡检 N 次。
|
||||
// InspectionScheduler 本身有 30s tick,到点自然会把到期设备加入队列。
|
||||
const wasRunning = _scheduler.isRunning();
|
||||
_scheduler.start();
|
||||
if (wasRunning && Object.keys(_hostConfigs || {}).length > 0) {
|
||||
// 已在跑 → 立即触发一次 scanAllNow,把新 hostConfigs 对应的设备加入队列
|
||||
setImmediate(() => {
|
||||
try {
|
||||
_scheduler.scanAllNow();
|
||||
} catch (e) {
|
||||
console.log("[Inspection] 触发立即巡检失败:", e.message);
|
||||
}
|
||||
});
|
||||
if (!wasRunning) {
|
||||
console.log("[Inspection] scheduler 已启动,首次 hostConfigs=", Object.keys(_hostConfigs || {}).length);
|
||||
}
|
||||
return _scheduler.getStatus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user