-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·39 lines (33 loc) · 1.02 KB
/
server.js
File metadata and controls
executable file
·39 lines (33 loc) · 1.02 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
'use strict';
const cluster = require('cluster');
var nodejscore = require('nodejscore');
if (cluster.isMaster &&
process.execArgv.indexOf('--debug') < 0 &&
process.env.NODE_ENV !== 'test' &&
process.execArgv.indexOf('--singleProcess') < 0) {
var cpuCount = require('os').cpus().length;
for (var i = 0; i < cpuCount; i++) {
console.log('forking ', i);
cluster.fork();
}
cluster.on('exit', function (worker) {
console.log('Worker ', worker.id, ' died :(');
cluster.fork();
});
} else {
var workerid = !cluster.isMaster ? cluster.worker.id : 0;
nodejscore.runInstance({
workerid: workerid
}, function (app) {
var config = app.config.clean,
port = config.https && config.https.port ? config.https.port : config.http.port;
console.log(
'Dexter\'s app started on port ',
port,
' (',
process.env.NODE_ENV,
') cluster.worker.id ',
workerid
);
});
}