kill server child process on various signals
This commit is contained in:
parent
490fdf26b3
commit
9683c4f41c
1 changed files with 7 additions and 4 deletions
|
@ -403,11 +403,14 @@ function main() {
|
|||
const bridge = new Bridge();
|
||||
bridge.start();
|
||||
|
||||
process.on("beforeExit", () => {
|
||||
if (bridge.process) {
|
||||
console.log("server process: killing on parent exit");
|
||||
const onServerClosing = () => {
|
||||
if (bridge.process)
|
||||
bridge.process.kill("SIGINT");
|
||||
}
|
||||
process.exit();
|
||||
};
|
||||
|
||||
['exit', 'SIGINT', 'SIGUSR1', 'SIGUSR2', 'uncaughtException', 'SIGTERM'].forEach((eventType) => {
|
||||
process.on(eventType, onServerClosing);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue