bash - How do I get just the app id with PM2? -
say have app named "fizzbuzz". start pm2 start index.js --name="fizzbuzz" --watch
. automation purposes i'd id of app. can grep guess seems pm2 have out of box. can't find in docs. instance, i'd this:
$ pm2 id --name="fizzbuzz" 3
will have use grep , string manipulation in bash accomplish this?
since presumably can't add shell lines pm2, cannot use $$ variable provides current process' id. there way without resorting ps, grep, et al.
as long command pm2 start index.js --name="fizzbuzz" --watch
, this:
pm2 start index.js --name="fizzbuzz" --watch & fizz_pid=$!
the ampersand runs pm2 in background. fizz_pid=$!
writes process id of program last put background fizz_pid variable. (caveat: adding pipe |
after end of pm2 command break this.)
Comments
Post a Comment