node.js - Getting id of worker from inside worker process -


using node.js cluster module, straightforward id of worker process.

https://nodejs.org/api/cluster.html

that be:

cluster.on('fork', function (worker) {     console.log('a worker', worker.id, 'was forked.'); }); 

but how can id of worker inside worker itself? how come cluster module doesn't give worker id when cluster forks worker?

do have send worker it's cluster id master process?

i looking akin to:

process.id (as opposed process.pid)

or

process.worker.id 

in case, having trouble figuring out id of worker inside worker itself.

var cluster = require('cluster');  if (cluster.ismaster) {   console.log('i master');   cluster.fork();   cluster.fork(); } else if (cluster.isworker) {   console.log('i worker #' + cluster.worker.id); } 

as in here


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -