All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 2m44s
34 lines
730 B
JavaScript
34 lines
730 B
JavaScript
import { spawn } from "node:child_process";
|
|
|
|
const processes = [
|
|
spawn("node", ["server/dist/server.js"], { stdio: "inherit" }),
|
|
spawn("pnpm", ["--filter", "client", "start"], { stdio: "inherit" })
|
|
];
|
|
|
|
let stopping = false;
|
|
|
|
function stopAll(signal = "SIGTERM") {
|
|
stopping = true;
|
|
for (const child of processes) {
|
|
if (!child.killed) {
|
|
child.kill(signal);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
process.on(signal, () => {
|
|
stopAll(signal);
|
|
});
|
|
}
|
|
|
|
for (const child of processes) {
|
|
child.on("exit", (code, signal) => {
|
|
if (stopping) return;
|
|
|
|
stopping = true;
|
|
stopAll();
|
|
process.exit(code ?? (signal ? 1 : 0));
|
|
});
|
|
}
|