Browse Source

run webserver on all available cores, resolves #6

pull/158/head
Peter Johnson 10 years ago
parent
commit
df66dccbc2
  1. 29
      index.js
  2. 1
      package.json

29
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 );
}

1
package.json

@ -34,6 +34,7 @@
},
"dependencies": {
"async": "^0.9.0",
"cluster2": "^0.4.26",
"express": "^4.8.8",
"geojson": "^0.2.1",
"geojson-extent": "^0.3.1",

Loading…
Cancel
Save