forked from almero-digital-marketing/mikser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.js
43 lines (41 loc) · 1.14 KB
/
base.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
'use strict'
var cluster = require('cluster');
var Promise = require('bluebird');
var application = require('./lib/application');
var config = require('./lib/config');
var runtime = require('./lib/runtime');
var database = require('./lib/database');
var utils = require('./lib/utils');
var diagnostics = require('./lib/diagnostics');
var tools = require('./lib/tools');
var debug = require('./lib/debug');
var broker = require('./lib/broker');
var parser = require('./lib/parser');
module.exports = function(options) {
let mikser = application(options);
mikser.options.base = true;
mikser.run = function() {
return Promise.resolve(mikser)
.then(debug)
.then(broker)
.then(config)
.then(runtime)
.then(database)
.then(parser)
.then(utils)
.then(tools)
.then(diagnostics)
.then(() => mikser.emit('mikser.init', cluster.isMaster).return(mikser))
.then((mikser) => {
if (cluster.isMaster) {
console.log('Mikser: Loaded');
mikser.loadPlugins().then(() => {
mikser.cli.init(true);
});
} else {
mikser.loadPlugins().then(mikser.joinMaster);
}
}).return(mikser);
}
return mikser;
}