I have backend node app, that is run by pm2 in cluster mode. I'm running fixed 2 instances.
Is there a way to identify instance name or number from within executed app?
App name is "test", I would like to get from within the app "test 1" and "test 2" for given instance.
You'll need to use two environment variables set by pm2:
process.env.pm_id
is automatically set to the instance id (0
, 1
, ...).
process.env.name
is set to the app name (in your case test
).