Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
import repl from "node:repl";
import cluster from "node:cluster";
import { initDb } from "../db/postgre.js";
import config from "../config/index.js";
/**
* Init worker process
*/ export async function workerMain() {
await initDb();
if (!config.onlyQueueProcessor) {
// start server
await import("../server/index.js").then((x)=>x.default());
}
// start job queue
import("../queue/index.js").then((x)=>x.default());
if (cluster.isWorker) {
// Send a 'ready' message to parent process
process.send("ready");
cluster.worker.on("message", (message, handle)=>{
if (message == "debug-shell") spawnWorkerShell(handle);
});
}
}
function spawnWorkerShell(socket) {
const r = repl.start({
input: socket,
output: socket
});
r.defineCommand("worker", (iid)=>{
r.close();
const id = parseInt(iid.trim());
cluster.workers[id].send("debug-shell", socket);
});
}