Created
December 2, 2014 16:41
-
-
Save limianwang/55e8a0b6ca816e024358 to your computer and use it in GitHub Desktop.
cluster
This file contains 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'; | |
var cluster = require('cluster'); | |
if(cluster.isMaster) { | |
console.log('master', process.pid); | |
var worker = cluster.fork(); | |
console.log('forked child pid: ', worker.process.pid); | |
} else { | |
console.log('child', process.pid); | |
} | |
/* | |
$ node foo.js | |
master 36520 | |
forked child pid: 36521 | |
child 36521 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment