-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
37 lines (30 loc) · 939 Bytes
/
start.js
File metadata and controls
37 lines (30 loc) · 939 Bytes
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
var cp = require('child_process');
var config = require(process.argv[2] + '/config.js');
if (config.DYNAMIC){
var hosts = (config.DYNAMICHOST instanceof Array) ? config.DYNAMICHOST : [config.DYNAMICHOST];
hosts.forEach(function(dt){
var host = dt.host;
var port = dt.port;
if (host === 'localhost'){
var child = cp.fork('./init.js', [process.argv[2],port]);
child.on('close',close.bind(null,port));
child.on('message',messagehandler);
} else {
console.log('Not localhost, ' + host + ', ignoring...')
}
});
}
function stdout(data){
console.log(data);
}
function stderr(data){
console.error(data);
}
function close(port,status){
console.error('Server in port ' + port + ' died out with status ' + status + '; respawning...');
var child = cp.fork('./init.js', [process.argv[2],port]);
child.on('close',close.bind(null,port));
child.on('message',messagehandler);
}
function messagehandler(type,data){
}