Skip to content

Instantly share code, notes, and snippets.

@evanlucas
Last active January 28, 2016 18:22
Show Gist options
  • Save evanlucas/c1835d0c960f3fc70636 to your computer and use it in GitHub Desktop.
Save evanlucas/c1835d0c960f3fc70636 to your computer and use it in GitHub Desktop.
'use strict'
const http = require('http')
http.createServer((req, res) => {
res.end()
}).listen(8000, (err) => {
if (err) throw err
})
'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