Last active
January 28, 2016 18:22
-
-
Save evanlucas/c1835d0c960f3fc70636 to your computer and use it in GitHub Desktop.
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
'use strict' | |
const http = require('http') | |
http.createServer((req, res) => { | |
res.end() | |
}).listen(8000, (err) => { | |
if (err) throw err | |
}) |
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
'use strict' | |
const cluster = require('cluster') | |
const http = require('http') | |
const cpus = require('os').cpus().length | |
if (cluster.isMaster) { | |
for (var i = 0; i < cpus; i++) { | |
cluster.fork() | |
} | |
cluster.on('exit', function(w, c, s) { | |
console.log(`exit ${w.process.pid} died`) | |
}) | |
} else { | |
http.createServer((req, res) => { | |
res.end() | |
}).listen(8000, (err) => { | |
if (err) throw err | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment