From 7bbf8c19dbe20ff6070a38e61dce9de24a4745d1 Mon Sep 17 00:00:00 2001 From: Veeck Date: Thu, 13 Oct 2022 21:38:04 +0200 Subject: [PATCH] Wait till all node_helper are started before finishing startup (#2928) In response to #2487 this implements a Promise.all for the node_helper start calls Co-authored-by: veeck --- CHANGELOG.md | 1 + js/app.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53adcc6983..7628820d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Special thanks to: @rejas, @sdetweil ### Updated - Cleaned up test directory +- Wait for all modules to start before declaring the system ready (#2487) - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated da translation - Rework weather module diff --git a/js/app.js b/js/app.js index c3d6b214de..bd3f81d25f 100644 --- a/js/app.js +++ b/js/app.js @@ -226,17 +226,21 @@ function App() { httpServer = new Server(config, function (app, io) { Log.log("Server started ..."); + const nodePromises = []; + for (let nodeHelper of nodeHelpers) { nodeHelper.setExpressApp(app); nodeHelper.setSocketIO(io); - nodeHelper.start(); + nodePromises.push(nodeHelper.start()); } - Log.log("Sockets connected & modules started ..."); + Promise.allSettled(nodePromises).then(() => { + Log.log("Sockets connected & modules started ..."); - if (typeof callback === "function") { - callback(config); - } + if (typeof callback === "function") { + callback(config); + } + }); }); }); });