From c15b31b374d172d99f729b174a84e7ed6f30fecc Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Wed, 15 Sep 2021 21:09:31 +0200 Subject: [PATCH] close server --- js/app.js | 4 +++- js/server.js | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index 6315370b..9ead45b2 100644 --- a/js/app.js +++ b/js/app.js @@ -48,6 +48,7 @@ process.on("uncaughtException", function (err) { */ function App() { let nodeHelpers = []; + let httpServer; /** * Loads the config file. Combines it with the defaults, and runs the @@ -222,7 +223,7 @@ function App() { } loadModules(modules, function () { - const server = new Server(config, function (app, io) { + httpServer = new Server(config, function (app, io) { Log.log("Server started ..."); for (let nodeHelper of nodeHelpers) { @@ -253,6 +254,7 @@ function App() { nodeHelper.stop(); } } + httpServer.close(); }; /** diff --git a/js/server.js b/js/server.js index 5ce9435d..8db8b48c 100644 --- a/js/server.js +++ b/js/server.js @@ -92,6 +92,11 @@ function Server(config, callback) { if (typeof callback === "function") { callback(app, io); } + + this.close = function () { + server.close(); + } + } module.exports = Server;