forked from linagora/hublin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
55 lines (49 loc) · 1.37 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
var async = require('async');
var moduleManager = require('./backend/module-manager');
var core = require('./backend/core');
var logger = core.logger;
var config = core.config('default');
var modules = config.modules;
function setupServerEnvironment(callback) {
moduleManager.setupServerEnvironment().then(function() {
return callback();
},
function(err) {
return callback(err);
});
}
function fireAppState(state) {
return function fireApp(callback) {
moduleManager.manager.load(['linagora.io.meetings.webserver', 'linagora.io.meetings.wsserver', 'linagora.io.webrtc']).then(
function() {
moduleManager.manager.fire(state, modules).then(function() {
callback(null);
}, function(err) {
callback(err);
})
},
function(err) {
callback(err);
}
);
};
}
function initCore(callback) {
core.init(function(err) {
if (!err) {
logger.info('Meetings Core bootstraped, configured in %s mode', process.env.NODE_ENV);
}
callback(err);
});
}
async.series([setupServerEnvironment, fireAppState('lib'), initCore, fireAppState('start')], function(err) {
if (err) {
logger.error('Fatal error:', err);
if (err.stack) {
logger.error(err.stack);
}
process.exit(1);
}
logger.info('Linagora Meetings is now started on node %s', process.version);
});