diff --git a/scripts/minecraft.js b/scripts/minecraft.js index e438c1c..86e6e77 100644 --- a/scripts/minecraft.js +++ b/scripts/minecraft.js @@ -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); }); }