diff --git a/.travis.yml b/.travis.yml index 4ca5cafc..f2a4e06a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,5 @@ language: node_js script: "npm run unit" node_js: - "0.10" + - "0.12" sudo: false \ No newline at end of file diff --git a/index.js b/index.js index 2e2e47bf..5f043b26 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,20 @@ -var cluster = require('cluster'), - app = require('./app'), - multicore = false, - port = ( process.env.PORT || 3100 ); +var Cluster = require('cluster2'), + app = require('./app'), + 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){ - console.log( 'listening on ' + port ); - app.listen( process.env.PORT || 3100 ); +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( port ); +} \ No newline at end of file diff --git a/package.json b/package.json index df28593e..dcf30f49 100644 --- a/package.json +++ b/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",