Browse Source

Merge pull request #158 from pelias/multicore

run webserver on all available cores, resolves #6
pull/179/merge
Peter Johnson a.k.a. insertcoffee 10 years ago
parent
commit
342e0f1ed4
  1. 1
      .travis.yml
  2. 25
      index.js
  3. 1
      package.json

1
.travis.yml

@ -2,4 +2,5 @@ language: node_js
script: "npm run unit"
node_js:
- "0.10"
- "0.12"
sudo: false

25
index.js

@ -1,17 +1,20 @@
var cluster = require('cluster'),
var Cluster = require('cluster2'),
app = require('./app'),
multicore = false,
port = ( process.env.PORT || 3100 );
port = ( process.env.PORT || 3100 ),
multicore = true;
/** cluster webserver across all cores **/
// if( multicore ){
// @todo: not finished yet
// cluster(app)
// .use(cluster.stats())
// .listen( process.env.PORT || 3100 );
// }
if (!multicore){
if( multicore ){
var c = new Cluster({ port: port });
c.listen(function(cb){
console.log( 'worker: listening on ' + port );
cb(app);
});
}
/** run server on the default setup (single core) **/
else {
console.log( 'listening on ' + port );
app.listen( process.env.PORT || 3100 );
app.listen( port );
}

1
package.json

@ -34,6 +34,7 @@
},
"dependencies": {
"async": "^0.9.0",
"cluster2": "git://github.com/missinglink/cluster2.git#node_zero_twelve",
"express": "^4.8.8",
"geojson": "^0.2.1",
"geojson-extent": "^0.3.1",

Loading…
Cancel
Save