kill server child process on various signals

This commit is contained in:
hippoz 2022-03-12 18:04:18 +02:00
parent 490fdf26b3
commit 9683c4f41c
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -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);
});
}