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" script: "npm run unit"
node_js: node_js:
- "0.10" - "0.10"
- "0.12"
sudo: false sudo: false

25
index.js

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

1
package.json

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

Loading…
Cancel
Save