phase3(daemon): 监工 tick(spawn worker)+ ingest(outbox→DB)+ reaper + reconcile 接真判活
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -6,6 +6,7 @@ import { registerStatic } from '../api/static.js';
|
||||
import { loadConfig } from './config.js';
|
||||
import { startOrchestrator } from './orchestrator.js';
|
||||
import { startNotifier } from './notify.js';
|
||||
import { isWorkerAlive, heartbeatAgeMs } from '../executor/protocol.js';
|
||||
import { syncProject, todoJsonPath } from '../sync/todo-sync.js';
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,15 @@ async function main(): Promise<void> {
|
||||
const cfg = loadConfig();
|
||||
const store = new Store(cfg.dbFile);
|
||||
const rec = store.reconcileDeps(); // 启动对账:ready↔blocked 按依赖纠正存量数据
|
||||
const itr = store.reconcileInterrupted(); // 中断恢复:上次退出时在跑的任务重新入队
|
||||
// 中断恢复(多进程执行):用 worker_pid + 心跳真判活——worker 仍活则 re-adopt(daemon 续 ingest 其 outbox),
|
||||
// 死则回收(failTaskAttempt 收尾 + 重试/needs_attention)。
|
||||
const itr = store.reconcileInterrupted((run) =>
|
||||
run !== null && isWorkerAlive({
|
||||
pid: run.workerPid,
|
||||
heartbeatAgeMs: heartbeatAgeMs(run.id),
|
||||
startedAgeMs: Date.now() - Date.parse(run.startedAt),
|
||||
}),
|
||||
);
|
||||
const app = buildServer({ store, logger: true });
|
||||
|
||||
registerStatic(app); // Web 看板(web/ 静态文件)
|
||||
|
||||
Reference in New Issue
Block a user