Created
May 18, 2017 07:28
-
-
Save scq000/22e8bb5959917859d47e5af0c1f96eec to your computer and use it in GitHub Desktop.
多线程 node cluste
https://github.com/LearnBoost/cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
module.exports = http.createServer(function(req, res){ | |
console.log('%s %s', req.method, req.url); | |
var body = 'Hello World'; | |
res.writeHead(200, { 'Content-Length': body.length }); | |
res.end(body); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster') | |
, app = require('./app'); | |
cluster(app) | |
.use(cluster.logger('logs')) | |
.use(cluster.stats()) | |
.use(cluster.pidfiles('pids')) | |
.use(cluster.cli()) | |
.use(cluster.repl(8888)) | |
.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment