-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlively-events.js
More file actions
52 lines (50 loc) · 1.4 KB
/
lively-events.js
File metadata and controls
52 lines (50 loc) · 1.4 KB
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
var EventEmitter = require('events').EventEmitter;
var statusEmitter = new EventEmitter();
var workerLib = require('./lib/workerlib');
workerLib.initialize('lively_events', function() {
var deployment = require('./lib/deployment').init({workerLib: workerLib});
var workerManagement = require('./lib/worker_management').init({
workerLib: workerLib,
deployment: deployment
});
var subscriptionHandling = require('./lib/subscription_handling').init({
workerLib: workerLib,
workerManagement: workerManagement
});
var myutils = require('./lib/myutils');
var openStdin = function() {
var stdin = process.openStdin();
stdin.on('data', function(d) {
server.listen(parseInt(JSON.parse(d)));
});
stdin.on('end', function() {
workerLib.emitLivelyEvent('stopped');
console.log('lively-events.js exits');
process.exit(0);
});
}
var startup = function(startupCb) {
openStdin();
myutils.doLinear([
function(cb) {
deployment.checkAndDeploy(cb)
},
function(cb) {
subscriptionHandling.createEventsChangeListener(cb)
},
function(cb) {
subscriptionHandling.launchEventSystem(cb)
},
function(cb) {
deployment.createWorkerChangeListener();
cb();
}
], function() {
startupCb();
});
}
startup( function() {
statusEmitter.emit('started');
});
});
exports.statusEmitter = statusEmitter;