feat: complete TASK-WP0-07 supervisor
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user