Slim Docker runtime image
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 2m44s
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 2m44s
This commit is contained in:
33
scripts/start-production.mjs
Normal file
33
scripts/start-production.mjs
Normal file
@@ -0,0 +1,33 @@
|
||||
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));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user