-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
47 lines (39 loc) · 1.89 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
var spawn = require('child_process').spawn;
function log(prefix, data) {
data = ''+data; // make sure it's a string
data = data.replace(/\n$/, ''); // remove trailing \n
console.log(prefix+': '+data);
}
// should we load cloud server?
if(process.env.CLOUD_SERVER == 'true') {
// spawn the cloud server
var ui = spawn('node', ['cloud_server.js'], { cwd: __dirname + '/yeti/' });
ui.stdout.on('data', function(data){ log('cloud_server stdout', data); });
ui.stderr.on('data', function(data){ log('cloud_server stderr', data); });
ui.on('exit', function(code){ console.log('cloud_server exited with code '+code); });
console.log('cloud_server has been spawned');
} else {
var nko = require('nko')('sOlBQnEkup4F/fL4');
var node4 = '/opt/node-0.4.11/bin/node';
var node5 = '/opt/node-0.5.5/bin/node';
// spawn the UI
var ui = spawn(node4, ['server.js'], { cwd: __dirname + '/ui/' });
ui.stdout.on('data', function(data){ log('UI stdout', data); });
ui.stderr.on('data', function(data){ log('UI stderr', data); });
ui.on('exit', function(code){ console.log('UI exited with code '+code); });
console.log('UI has been spawned');
// spawn the MC
var mc = spawn(node4, ['mc.js'], { cwd: __dirname });
mc.stdout.on('data', function(data){ log('MC stdout', data); });
mc.stderr.on('data', function(data){ log('MC stderr', data); });
mc.on('exit', function(code){ console.log('MC exited with code '+code); });
console.log('MC has been spawned');
// spawn the cloud server
setTimeout(function(){
var ui = spawn(node5, ['cloud_server.js'], { cwd: __dirname + '/yeti/' });
ui.stdout.on('data', function(data){ log('cloud_server stdout', data); });
ui.stderr.on('data', function(data){ log('cloud_server stderr', data); });
ui.on('exit', function(code){ console.log('cloud_server exited with code '+code); });
console.log('cloud_server has been spawned');
},5000);
}