bigbluebutton-Github/bbb-webhooks/application.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

const config = require('config');
const Hook = require("./hook.js");
const IDMapping = require("./id_mapping.js");
const WebHooks = require("./web_hooks.js");
const WebServer = require("./web_server.js");
const redis = require("redis");
2017-09-15 01:09:02 +08:00
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.
// TODO: add port (-p) and log level (-l) to the command line args
module.exports = class Application {
constructor() {
this.webHooks = new WebHooks();
this.webServer = new WebServer();
}
start(callback) {
Hook.initialize(() => {
2017-09-15 01:09:02 +08:00
UserMapping.initialize(() => {
IDMapping.initialize(()=> {
async.parallel([
(callback) => { this.webServer.start(config.get("server.port"), config.get("server.bind"), callback) },
(callback) => { this.webServer.createPermanents(callback) },
(callback) => { this.webHooks.start(callback) }
], (err,results) => {
if(err != null) {}
typeof callback === 'function' ? callback() : undefined;
});
2017-09-15 01:09:02 +08:00
});
});
});
}
2019-03-30 04:52:58 +08:00
static redisPubSubClient() {
if (!Application._redisPubSubClient) {
Application._redisPubSubClient = redis.createClient( { host: config.get("redis.host"), port: config.get("redis.port") } );
}
return Application._redisPubSubClient;
}
static redisClient() {
if (!Application._redisClient) {
Application._redisClient = redis.createClient( { host: config.get("redis.host"), port: config.get("redis.port") } );
}
return Application._redisClient;
}
};