Path: blob/master/src/packages/conat/core/start-server.ts
1542 views
import { type Options } from "./server";1import { fork, type ChildProcess } from "node:child_process";2import { join } from "node:path";34const children: ChildProcess[] = [];5export function forkedConatServer(opts: Options) {6// this is fragile:7const child: ChildProcess = fork(8join(9__dirname,10"..",11"..",12"..",13"server",14"dist",15"conat",16"socketio",17"start-cluster-node.js",18),19);20children.push(child);21child.send(opts);22}2324function close() {25children.map((child) => child.kill("SIGKILL"));26}2728process.once("exit", () => {29close();30});3132["SIGTERM", "SIGQUIT"].forEach((sig) => {33process.once(sig, () => {34children.map((child) => child.kill(sig as any));35});36});373839