refactor: 重构巡检报告调度器,移除设备依赖并优化重试逻辑
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
- 重构调度器,改为注入获取设备ID的回调,移除硬依赖的deviceStore - 调整前端设备配置同步逻辑,改为直接读取解密后的本地存储 - 修改重试间隔,从15秒改为3秒,首次同步改为立即执行 - 调整日志级别,优化错误信息输出
This commit is contained in:
@@ -1164,6 +1164,7 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
readStorage: options.readStorage,
|
||||
writeStorage: options.writeStorage,
|
||||
runSnapshotFn: (deviceIds, trigger) => _runScheduledSnapshot(deviceIds, trigger),
|
||||
getAllDeviceIdsFn: () => Object.keys(_hostConfigs || {}),
|
||||
});
|
||||
}
|
||||
return saved;
|
||||
@@ -1178,6 +1179,7 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
readStorage: options.readStorage,
|
||||
writeStorage: options.writeStorage,
|
||||
runSnapshotFn: (deviceIds, trigger) => _runScheduledSnapshot(deviceIds, trigger),
|
||||
getAllDeviceIdsFn: () => Object.keys(_hostConfigs || {}),
|
||||
});
|
||||
} else if (!cfg.enabled && reportScheduler.isRunning()) {
|
||||
reportScheduler.stop();
|
||||
@@ -1425,24 +1427,8 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
|
||||
console.log("[Inspection] IPC handlers 已注册");
|
||||
|
||||
return {
|
||||
getScheduler: () => _scheduler,
|
||||
createScheduler: (opts) => {
|
||||
_scheduler = new InspectionScheduler({
|
||||
readFn,
|
||||
writeFn,
|
||||
execFn: execCommand,
|
||||
onAlertChanged: broadcastAlertChanged,
|
||||
...opts,
|
||||
});
|
||||
return _scheduler;
|
||||
},
|
||||
};
|
||||
|
||||
// ─── Electron 启动时自动启动 reportScheduler ───
|
||||
// 负责:per-device 定时快照 tick(主进程自身 SSH 执行) + dailyReport HH:MM 定时聚合
|
||||
// 主进程从 _hostConfigs(InspectionScheduler 已初始化的已解密 SSH 凭据缓存)取配置
|
||||
// 执行快照,不依赖 renderer 是否打开巡检报告页面
|
||||
async function _runScheduledSnapshot(deviceIds, trigger = "scheduled") {
|
||||
if (!_hostConfigs || Object.keys(_hostConfigs).length === 0) {
|
||||
console.warn("[reportScheduler] _hostConfigs 未初始化,定时快照跳过(需先打开监控页面让 renderer 同步 SSH 凭据到主进程)");
|
||||
@@ -1495,6 +1481,7 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
readStorage: readFn,
|
||||
writeStorage: writeFn,
|
||||
runSnapshotFn: (deviceIds, trigger) => _runScheduledSnapshot(deviceIds, trigger),
|
||||
getAllDeviceIdsFn: () => Object.keys(_hostConfigs || {}),
|
||||
});
|
||||
console.error("[RS_DEBUG] ✅ start() 已调用完成");
|
||||
} else {
|
||||
@@ -1503,6 +1490,20 @@ function registerInspectionHandlers(ipcMain, options) {
|
||||
} catch (e) {
|
||||
console.error("[RS_DEBUG] ❌ 启动失败:", e?.message || String(e), e?.stack);
|
||||
}
|
||||
|
||||
return {
|
||||
getScheduler: () => _scheduler,
|
||||
createScheduler: (opts) => {
|
||||
_scheduler = new InspectionScheduler({
|
||||
readFn,
|
||||
writeFn,
|
||||
execFn: execCommand,
|
||||
onAlertChanged: broadcastAlertChanged,
|
||||
...opts,
|
||||
});
|
||||
return _scheduler;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user