Say I have an app named "fizzbuzz". I start it with pm2 start index.js --name="fizzbuzz" --watch
. For automation purposes I'd like to just get the id of the app. I can grep it I guess but it seems like something that PM2 would have out of the box. I can't find it in the docs. For instance, I'd like to do this:
$ pm2 id --name="fizzbuzz"
3
Will I have to use grep and string manipulation in bash to accomplish this?
Check this link out.
process.env.pm_id
is the answer. I tested it and it's ok.