feat: complete TASK-WP0-07 supervisor

This commit is contained in:
suyx
2026-07-27 23:28:36 +08:00
parent 2dd6f5c2c2
commit 096a1f1279
22 changed files with 1717 additions and 6 deletions
+11
View File
@@ -1,5 +1,7 @@
import { parentPort } from "node:worker_threads";
import { attachWorkerSupervisorControl, initializeWorkerCredentialClient, receiveWorkerCredentials } from "./supervisor-channel.js";
export function handleWorkerProbe(message: unknown) {
return message === "ping" ? "pong" : null;
}
@@ -11,3 +13,12 @@ if (workerPort) {
workerPort.postMessage(handleWorkerProbe(message));
});
}
if (!workerPort && process.argv.includes("--dada-credential-stdin")) {
initializeWorkerCredentialClient(await receiveWorkerCredentials());
const controlPipeIndex = process.argv.indexOf("--dada-control-pipe");
const controlPipe = process.argv[controlPipeIndex + 1];
if (controlPipeIndex < 0 || !controlPipe) throw new Error("Supervisor control pipe name is required.");
const keepAlive = setInterval(() => undefined, 30_000);
attachWorkerSupervisorControl(controlPipe, () => clearInterval(keepAlive));
}