pm2 process manager not working
Asked Answered
E

4

6

I install the pm2 using npm install -g pm2 then when I run my node application using

pm2 start app.js

nothing is happening. when I run the command in terminal, it just go down another line. No errors or warnings shows in the terminal. I can run the application using nodejs app.js . Any kind of help would be appreciated. Thanks.

Esprit answered 28/7, 2014 at 9:54 Comment(2)
Are you sure it's not running? Try running it as above and then using pm2 list. There's a good chance it's just running in the background.Supportable
Generally when using pm2 "nothing is happening" is the correct expected output that indicates tha pmw is working perfectly. PM2 stores all your console.log() in a log file that can be viewed by using the pm2 logs command. This is a very useful feature which automatically implements logging for you (instead of manually using some logging library like winston or log4js etc.) and also decouples the logging logic completely from your application (which is a good thing)Sobriquet
M
1

I suppose it happens because of the node.js executable, if you are in Ubuntu install nodejs-legacy to enable the correct "node" executable link, I think pm2 is trying to use this one.

Mistranslate answered 11/12, 2014 at 20:38 Comment(0)
C
1

First stop and delete all processes by running pm2 delete all. Then run pm2 start app.js. Check the logs by running pm2 logs

Cleanshaven answered 27/12, 2017 at 9:40 Comment(0)
M
0
  1. use ps aux|grep node check the node is already running?
  2. use pm2 list check you process is running?
  3. check the pid file of you process and do the needful, kill may be.
Marciano answered 1/6, 2015 at 6:43 Comment(0)
N
0

I observed this behaviour after having a disconnect in ssh connection, while checking the logs using "pm2 log MyAppName". The log process somehow was still opened in background and blocked pm2 insomuch that it didn't react to commands (pm2 log MyAppName, pm2 restart MyAppName...).

The solution was for me to kill the process and everything worked afterwards:

Either use sudo killall node or retrieve process id of log command using ps aux | grep node and sudo kill PROCESS_ID to kill the process.

Nucleate answered 23/11, 2022 at 0:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.