Skip to content

Commit

Permalink
testing http server
Browse files Browse the repository at this point in the history
  • Loading branch information
fcirone committed Jul 20, 2016
1 parent a3c73b9 commit f799027
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index-http-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var cluster = require("cluster");
var http = require("http");
var numCPUs = require("os").cpus().length;
var port = 8888;

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

cluster.on('online', function(worker) {
console.log('Worker ' + worker.process.pid + ' is online');
});

cluster.on("exit", function(worker, code, signal) {
cluster.fork();
});
} else {
http.createServer(function(request, response) {
console.log("Request for: " + request.url + " on process " + process.pid);
response.writeHead(200);
response.end("hello world\n");
}).listen(port);
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"blitzkrieg": "^1.0.0",
"crypto": "0.0.3",
"express": "^4.14.0",
"http": "0.0.0",
"throng": "^4.0.0"
}
}

0 comments on commit f799027

Please sign in to comment.