Skip to content

Commit 229b398

Browse files
committed
add missing file
1 parent 8a82608 commit 229b398

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { fork, type ChildProcess } from "node:child_process";
2+
import { join } from "node:path";
3+
4+
const children: ChildProcess[] = [];
5+
export function createForkedPersistServer() {
6+
const child: ChildProcess = fork(join(__dirname, "start-persist-node.js"));
7+
children.push(child);
8+
}
9+
10+
function close() {
11+
// We do NOT send SIGKILL here, since we very much want the processes to
12+
// have a proper clean shutdown, so no data from the sqlite databases they
13+
// are managing gets lost.
14+
children.map((child) => child.kill("SIGTERM"));
15+
}
16+
17+
process.once("exit", () => {
18+
close();
19+
});
20+
21+
["SIGTERM", "SIGQUIT"].forEach((sig) => {
22+
process.once(sig, () => {
23+
children.map((child) => child.kill(sig as any));
24+
});
25+
});

0 commit comments

Comments
 (0)