Pm2 - How to start, if not running, kill and start if it is running

I am trying to start pm2 if it is not running, or to kill it and run if it is, how can I achieve this behavior in the WINDOWS command line interface?

There are many solutions using grep in linux, but nothing for Windows, any idea on how to get this behavior?

The documentation states that it pm2 start -f app.jswill kill and launch the application, but actually just creates another instance.

+4
source share
1 answer

I would do this:

pm2 stop myprocess.js #this will just say process not found
pm2 start myprocess.js

Or if you want to clear everything:

pm2 kill
pm2 stop

If you want more advanced features, check out the pm2 api .

+2
source

Source: https://habr.com/ru/post/1623855/