File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/packages/server/conat/persist Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments