naught icon indicating copy to clipboard operation
naught copied to clipboard

How can I distinguish between worker processes?

Open bmiller59 opened this issue 8 years ago • 2 comments

Hello. I would like to distinguish between the worker processes and run some code only in one process. Normally with node clusters you can do this by checking the cluster.isMaster property, but that does not work with naught because naught is the master.

Is there another way to distinguish and run some code only on 1 process per server while running under naught?

Thanks! Otherwise very pleased with naught.

bmiller59 avatar Jul 13 '16 01:07 bmiller59

Hello, The node cluster (same with naught) provides an environment variable to identify the current worker :

process.env['WORKER_ID']

my2cents

openhoat avatar Sep 02 '16 05:09 openhoat

In my version (which may be older), it's process.env['NAUGHT_WORKER'].

NoelBaron avatar May 21 '18 14:05 NoelBaron