Skip to content

Commit

Permalink
Merge pull request #9 from benma/master
Browse files Browse the repository at this point in the history
node.js using three cores
  • Loading branch information
snoyberg committed Apr 17, 2013
2 parents 464260d + 6cbed69 commit f49720b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pong/node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('PONG');
}).listen(3000, "127.0.0.1");
var cluster = require('cluster');

if(cluster.isMaster) {
for(var i = 0; i < 3; i++) {
cluster.fork();
}
} else {
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('PONG');
}).listen(3000, "127.0.0.1");
}

0 comments on commit f49720b

Please sign in to comment.