-
-
Save vanquyet94/91726685dd6737be6e4310e5d1b70dfc to your computer and use it in GitHub Desktop.
what is cluster.worker.id?
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
var cluster = require('cluster'); | |
if (cluster.isMaster) { | |
for (var i = 0; i < 4; ++i) { | |
cluster.fork(); | |
} | |
} else { | |
console.log(process.pid, cluster.worker.id); | |
} | |
/* output is here | |
$ node app.js | |
13747 1 | |
13750 4 | |
13748 2 | |
13749 3 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment