pm2 list shows empty but pm2 is running

Created on 11 Mar 2018  ยท  8Comments  ยท  Source: Unitech/pm2

I am running node server in autoscaling and i have written few commands in bootstrap script to start pm2 after deployment.
pm2 starts after deployment as expected but when i check pm2 list, it shows empty, while checking 'netstat -tnlp' i see node server already running on port 8080.

Bootstrap script:
cd /opt
npm install
pm2 start server
service nginx start

netstat -tnlp:
tcp 0 0 :::8080 :::* LISTEN 3041/node /opt/serv
tcp 0 0 :::22 :::* LISTEN 2771/sshd

pm2 list:
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ App name โ”‚ id โ”‚ mode โ”‚ pid โ”‚ status โ”‚ restart โ”‚ uptime โ”‚ cpu โ”‚ mem โ”‚ user โ”‚ watching โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Use pm2 show <id|name> to get more details about an app

Now if i try to run pm2 again by killing the old one with pkill -f PM2 and re run
pm2 start server, everything works well and it shows the id in pm2 list as well but i want this to be run in aws userdata script so that autoscaling could work.

I also tried pkill -f PM2 in userdata and then re-run pm2 start server but that didn't help as well.

More Info:
root user is running pm2
and i am also checking the above things from root user

I have googled enough :)

Regards,
Yash

stale

Most helpful comment

Hey Marc,

sudo pkill -f PM2
sudo pm2 start server.js -- prod
sudo pm2 startup
sudo pm2 save
sudo service nginx start

This worked for me :)

Regards,
Yash

All 8 comments

Hi Yash,

did you already solve the problem? I'm running into same issue over here...

Regards,
Marc

Hey Marc,

sudo pkill -f PM2
sudo pm2 start server.js -- prod
sudo pm2 startup
sudo pm2 save
sudo service nginx start

This worked for me :)

Regards,
Yash

Still having problems with pm2-dev start config.yml. But pm2-runtime works fine. Can someone check this one, please?

Hey Marc,

sudo pkill -f PM2
sudo pm2 start server.js -- prod
sudo pm2 startup
sudo pm2 save
sudo service nginx start

This worked for me :)

Regards,
Yash

work like a charm

@NahuPerez Good to know buddy that it's working for you :)

1

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I am running into a similar problem at the moment. I believe it is because of https://github.com/Unitech/pm2/issues/992.

In short, PM2 is run by two different user types, and I am only able to see processes running that were invoked by my user. For example:

  • root user - what CodeDeploy uses to build, deploy and run processes on my server
  • my user /home/ubuntu/<me> - what I use when I login to my server to manually troubleshoot things on server
Was this page helpful?
0 / 5 - 0 ratings

Related issues

FujiHaruka picture FujiHaruka  ยท  3Comments

psparago picture psparago  ยท  3Comments

webchaz picture webchaz  ยท  3Comments

phra picture phra  ยท  3Comments

jubairsaidi picture jubairsaidi  ยท  3Comments