Commit 14af5095 authored by Mike Shoup's avatar Mike Shoup

Use multi-process express for node

parent 622a62f4
var express = require("express");
var app = express();
var cluster = require("cluster");
var routes = require("./routes/routes.js")(app);
var server = app.listen(8000, function () {
console.log("Listening on port %s...", server.address().port);
});
if (cluster.isMaster) {
// Master process code
var cpuCount = require('os').cpus().length;
for (var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
} else {
// Worker process code
var express = require("express");
var app = express();
var routes = require("./routes/routes.js")(app);
var server = app.listen(8000, function () {
console.log("Listening on port %s...", server.address().port);
});
}
......@@ -7,6 +7,7 @@
},
"author": "Mike Shoup",
"dependencies": {
"cluster": "^0.7.7",
"express": "^4.16.3"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment