Skip to content

Instantly share code, notes, and snippets.

@rudyjahchan
Created February 28, 2014 17:06
Show Gist options
  • Save rudyjahchan/9275029 to your computer and use it in GitHub Desktop.
Save rudyjahchan/9275029 to your computer and use it in GitHub Desktop.
cluster = require 'cluster'
numCPUs = require('os').cpus().length
exports = module.exports = launch: ->
console.log 'Before the fork'
if (cluster.isMaster)
console.log 'I am the master, launching workers!'
cluster.fork() for i in [0...numCPUs]
else
console.log 'I am a worker!'
console.log 'After the fork'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment