Browse Source

Merge pull request #585 from pelias/remove_cluster2

remove cluster2 module
pull/586/head
Peter Johnson a.k.a. insertcoffee 8 years ago committed by GitHub
parent
commit
e7b6359f89
  1. 24
      index.js
  2. 1
      package.json

24
index.js

@ -1,20 +1,32 @@
var Cluster = require('cluster2'),
var cluster = require('cluster'),
app = require('./app'),
port = ( process.env.PORT || 3100 ),
multicore = true;
/** cluster webserver across all cores **/
if( multicore ){
var c = new Cluster({ port: port });
c.listen(function(cb){
var numCPUs = require('os').cpus().length;
if( cluster.isMaster ){
// fork workers
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function( worker, code, signal ){
console.log('worker ' + worker.process.pid + ' died');
});
} else {
app.listen( port );
console.log( 'worker: listening on ' + port );
cb(app);
});
}
}
/** run server on the default setup (single core) **/
else {
console.log( 'listening on ' + port );
app.listen( port );
}
}

1
package.json

@ -35,7 +35,6 @@
"dependencies": {
"async": "^1.5.2",
"check-types": "^7.0.0",
"cluster2": "git://github.com/missinglink/cluster2.git#node_zero_twelve",
"elasticsearch": "^11.0.0",
"elasticsearch-exceptions": "0.0.4",
"express": "^4.8.8",

Loading…
Cancel
Save