From 7f4ddec706a93742e13d38c1e964b63653556f51 Mon Sep 17 00:00:00 2001 From: italo <italojmf@gmail.com> Date: Mon, 6 Nov 2017 18:43:05 +0000 Subject: [PATCH] Add a callback to let components know app started --- bbb-webhooks/application.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bbb-webhooks/application.js b/bbb-webhooks/application.js index 2a6c015cea..2817826712 100644 --- a/bbb-webhooks/application.js +++ b/bbb-webhooks/application.js @@ -5,6 +5,7 @@ const WebHooks = require("./web_hooks.js"); const WebServer = require("./web_server.js"); const redis = require("redis"); const UserMapping = require("./userMapping.js"); +const async = require("async"); // Class that defines the application. Listens for events on redis and starts the // process to perform the callback calls. @@ -18,13 +19,18 @@ module.exports = class Application { this.webServer = new WebServer(); } - start() { + start(callback) { Hook.initialize(() => { UserMapping.initialize(() => { IDMapping.initialize(()=> { - this.webServer.start(config.server.port); - this.webServer.createPermanents(); - this.webHooks.start(); + async.parallel([ + (callback) => { this.webServer.start(config.server.port, callback) }, + (callback) => { this.webServer.createPermanents(callback) }, + (callback) => { this.webHooks.start(callback) } + ], (err,results) => { + if(err != null) {} + typeof callback === 'function' ? callback() : undefined; + }); }); }); }); -- GitLab