How to disable/stop a pm2 module?

negrotico19 picture negrotico19 · Apr 16, 2018 · Viewed 19.8k times · Source

Is it possible to stop or disable a pm2 module ? I did install the pm2-logrotate module but recently the community found an issue which is affecting our services and we need to stop or disable the module in top priority.

The module is continuously restarting and the node application in is production. So we cannot just stop the pm2 and look for a fix.

nodejs version: "4.8.2"
pm2 version "2.7.2"
pm2-logrotate version "2.4.0"
OS-Release: "Raspbian Stretch"


$ pm2 describe pm2-logrotate | grep -i script
│ script path       │ /home/user/.pm2/node_modules/pm2-logrotate/app.js │
│ script args       │ N/A                                                     │
│ script id         │ 0                                                       │
$ pm2 describe pm2-logrotate | grep -i id
 Describing process with id 0 - name pm2-logrotate
│ pid path          │ /home/user/.pm2/pids/pm2-logrotate-0.pid          │
│ script id         │ 0                                                       │
$ cat /home/user/.pm2/pids/pm2-logrotate-0.pid
7723

Answer

Stamos picture Stamos · Apr 16, 2018

You can do pm2 describe pm2-logrotate. This will return alot of information. What you are looking for is script id

│ interpreter       │ node
│ interpreter args  │ N/A
│ script id         │ 0     
│ exec cwd          │ /home/user/.pm2/modules/pm2-logrotate/node_modules/pm2-logrotate
│ exec mode         │ fork_mode 
│ node.js version   │ 8.11.1

Now you know that the AppId is 0 so you can do

pm2 stop 0

and the module will stop.

You can always uninstall using

pm2 uninstall pm2-logrotate