-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathentrypoint.js
executable file
·46 lines (41 loc) · 1.12 KB
/
entrypoint.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
#!/bin/sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
var forever = require('forever');
if (process.argv[2] === "dispatcher") {
forever.start('examples/dispatcher/index.js', {
max: 1
});
} else if (process.argv[2] === "worker") {
var nginxDaemon = forever.start("-c/home/chatup/examples/chatWorker/nginx.conf", {
command: "/usr/local/nginx/sbin/nginx",
max: 1,
silent: false,
logFile: 'nginx.log'
});
nginxDaemon.on('exit', function() {
forever.stopAll();
process.exit(1);
});
if (process.argv[3] === "--use-container-ip") {
require('dns').lookup(require('os').hostname(), function (err, addr, fam) {
forever.start('examples/chatWorker/index.js', {
silent: false,
max: 1,
env: {
CHATUP_HOSTNAME: addr
}
});
})
} else {
var workerDaemon = forever.start('examples/chatWorker/index.js', {
silent: false,
max: 1
});
}
process.on('exit', function() {
forever.stopAll();
});
} else {
console.error('First arg should be "dispatcher" or "worker", got:', process.argv);
process.exit(1);
}