Skip to content

Commit

Permalink
using node clustering
Browse files Browse the repository at this point in the history
[#95]
  • Loading branch information
caspian311 committed May 11, 2014
1 parent e309a68 commit 53adb89
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,46 @@ var express = require('express')
, login = require('./app/login')
, logout = require('./app/logout')
, registration = require('./app/registration')
, authentication = require('./app/authentication');
, authentication = require('./app/authentication')
, cluster = require('cluster')
, os = require('os');

var app = express()
function startApp() {
var app = express()

app.use(express.logger('dev'))
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine', 'jade')
app.use(express.logger('dev'))
app.use(express.static(path.join(__dirname, 'public')))
app.set('view engine', 'jade')

app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.favicon())
app.use(express.cookieParser())
app.use(express.session({ secret: 'keyboard cat' }))
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.favicon())
app.use(express.cookieParser())
app.use(express.session({ secret: 'keyboard cat' }))

app.use(authentication)
app.use(authentication)

app.use(main)
app.use(queues)
app.use(cards)
app.use(login)
app.use(logout)
app.use(registration)
app.use(main)
app.use(queues)
app.use(cards)
app.use(login)
app.use(logout)
app.use(registration)

http.createServer(app).listen(3000, function(){
console.log("Express server listening on port 3000")
});
}

if (cluster.isMaster) {
for (var i = 0; i < os.cpus().length; i++) {
cluster.fork();
}

cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
startApp();
}

http.createServer(app).listen(3000, function(){
console.log("Express server listening on port 3000")
});

0 comments on commit 53adb89

Please sign in to comment.