It's possible to restart a certain group of applications with pm2? Something like pm2 restart service-*
restarting service-a and service-b? I found pm2 restart service-a
and pm2 restart all
, but nothing with wildcard. Of course I could write a shell script, but before I'm interested in the easiest way.
Asked
Active
Viewed 852 times
4

Rainer
- 1,067
- 2
- 14
- 29
1 Answers
1
Not sure if you still need this, but this works (on Linux anyway). It requires jq and tr.
pm2 restart $(pm2 jlist | jq -c '. | map(select(.name | index("service-.") == 0)) | .[] .pm_id' | tr '\n' ' ')
Basically you're using pm2 jlist to generate a json file of all the processes, jq to filter all the names starting with "service-", then output all the pm_ids, concatenate them and use them for the pm2 restart.

Vincent
- 11
- 1