Skip to content

Instantly share code, notes, and snippets.

@ando-takahiro
Created November 20, 2012 08:26
Show Gist options
  • Save ando-takahiro/4116721 to your computer and use it in GitHub Desktop.
Save ando-takahiro/4116721 to your computer and use it in GitHub Desktop.
what is cluster.worker.id?
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
*/
@ando-takahiro
Copy link
Author

cluster.worker.id looks just a number.

@ando-takahiro
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment