From f0b2623f99ac049206fd2feaab6eb4a8695c53d8 Mon Sep 17 00:00:00 2001 From: Pedro Amaro Date: Sat, 14 Sep 2019 03:47:52 +0100 Subject: [PATCH] Fixed Brikkit continuing to run when Brickadia crashed or exited --- brickadia.js | 3 +-- brikkit.js | 3 +++ server.js | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/brickadia.js b/brickadia.js index 7ecf22a..735dd2c 100644 --- a/brickadia.js +++ b/brickadia.js @@ -87,9 +87,8 @@ class Brickadia { process.exit(); }); - process.on('uncaughtException', err => { + process.on('uncaughtException', _err => { sp.kill(); - throw err; }); } diff --git a/brikkit.js b/brikkit.js index 51c637a..dcded45 100644 --- a/brikkit.js +++ b/brikkit.js @@ -43,6 +43,9 @@ class Brikkit { this._pluginSystem = new PluginSystem(); this._brickadia.on('out', line => this._handleBrickadiaLine(line)); + this._brickadia.on('close', () => { + throw new Error('Brickadia closed (probable crash)'); + }); this._terminal = new Terminal(); this._terminal.on('out', line => { diff --git a/server.js b/server.js index eb3559b..2eaad17 100644 --- a/server.js +++ b/server.js @@ -35,9 +35,10 @@ function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } -process.on('uncaughtException', async err => { +process.on('uncaughtException', err => { console.log(' --- SERVER END --- '); - stream.end(); + console.log(err.stack); fs.appendFileSync(logFile, err.stack); + process.exit(); }); \ No newline at end of file