Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apps not showing on list #992

Closed
marcoschicote opened this issue Feb 3, 2015 · 19 comments
Closed

Apps not showing on list #992

marcoschicote opened this issue Feb 3, 2015 · 19 comments

Comments

@marcoschicote
Copy link

Hi
I've started two apps with pm2. Both apps are working (I get a response from the API) but they don't show when I execute pm2 list. Any ideas on what can be causing this? I'm running a ec2 ubuntu instance.

deploy@ip-172-31-25-115:~$ ps aux | grep node
deploy    1515  0.2  6.5 789492 66724 ?        Ssl  15:25   0:00 node /srv/node/pse/source/app.js
deploy    1518  0.3  7.3 992580 74780 ?        Ssl  15:25   0:01 node /srv/node/pse/source/bj.js
deploy    1833  0.0  0.0  10440   932 pts/0    S+   15:30   0:00 grep --color=auto node
deploy@ip-172-31-25-115:~$ pm2 list
┌──────────┬────┬──────┬─────┬────────┬───────────┬────────┬────────┬──────────┐
│ App name │ id │ mode │ PID │ status │ restarted │ uptime │ memory │ watching │
└──────────┴────┴──────┴─────┴────────┴───────────┴────────┴────────┴──────────┘
 Use `pm2 info <id|name>` to get more details about an app

Thanks!

@benjdlambert
Copy link

+1, been getting this too recently.

@Unitech
Copy link
Owner

Unitech commented Feb 3, 2015

How did you start your apps? Different users?

@marcoschicote
Copy link
Author

I used this to start pm2

sudo npm install pm2 -g
pm2 ls
sudo env PATH=$PATH:`dirname $(which pm2)` pm2 startup ubuntu -u www-data

And my post-deploy hook ends with:

pm2 startOrRestart ecosystem.staging.json5 --env staging

which is executed with the deploy user. I tried executing the startup script with ubuntu user and deploy user, but neither work.

@soyuka
Copy link
Collaborator

soyuka commented Feb 3, 2015

So there is a user conflict here.

You need to install the package globally for your deploy user - using nvm it's easy as npm i pm2 -g without sudo.
Then:

sudo env PATH=$PATH:`dirname $(which pm2)` pm2 startup ubuntu -u deploy 
#notice the -u user must be the same as the one which installed pm2

And everything should work just fine!

Explanation:
The issue here is that every user is using a different pm2 socket to communicate with it's processes. So, when you start your processes as www-data, when the user deploy launches pm2 list there will be no processes. If www-data launched pm2 list he would see it's processes.

Hope that's clear enough ;).

@benjdlambert
Copy link

@soyuka everything works fine for me for a while, and then it disappears after using the API in node.

Let me see if I can get something together to consistently reproduce. Its intermittent at the min.

@benjdlambert
Copy link

The API in node is being used inside a PM2 launched process if that makes any difference?

@marcoschicote
Copy link
Author

@soyuka thanks for the explanation.
What I don't get is how do I tell pm2 to use www-data to start a process. Do I need to run pm2 start with such user?

@soyuka
Copy link
Collaborator

soyuka commented Feb 7, 2015

Yes.

Same virtual machine, 2 different users, 2 different node versions, 2 different pm2.

You'll notice that when I call pm2 list on the user I'm only retrieving it's own processes.

@benjdlambert
Copy link

@soyuka I couldn't replicate the issue when upgrading node versions.
Must have been something in there.

@dandv
Copy link
Contributor

dandv commented May 10, 2015

sudo env PATH=$PATH:dirname $(which pm2) pm2 startup ubuntu -u deploy

@soyuka, what does the -u deploy option do? It's not documented in pm2 startup --help. Running pm2 alone shoes the option, so perhaps it should be documented in pm2 startup --help as well?

@entropitor
Copy link

I seem to get the same error, but I can't even see the processes started by the same user. After a while, they just dissapear from the list, only that latest started apps appear. (There pid is saved in the same folder as the more recent ones, so I really don't get why this is happening).

@crobinson42
Copy link

i'm seeing this - same user, but not showing in the list:

root@therms-app-sandbox:~# lsof -i :1338
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
node    10305 root   36u  IPv6 4381592      0t0  TCP 159.203.240.135:1338->12.183.186.157:61005 (ESTABLISHED)
node    10305 root   37u  IPv6 4381593      0t0  TCP 159.203.240.135:1338->12.183.186.157:61006 (ESTABLISHED)
node    10305 root   38u  IPv6 4381651      0t0  TCP 159.203.240.135:1338->12.183.186.157:61008 (ESTABLISHED)
PM2     23518 root   13u  IPv6 4376105      0t0  TCP *:1338 (LISTEN)
root@therms-app-sandbox:~# pm2 list
┌──────────┬────┬──────┬─────┬────────┬─────────┬────────┬────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
└──────────┴────┴──────┴─────┴────────┴─────────┴────────┴────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app
root@therms-app-sandbox:~# 

i'm logged in as root and the running pm2 process was started by root in a different session... any explanation?

@jtanori
Copy link

jtanori commented Oct 13, 2016

Getting the same issue as you @crobinson42

Setup npm and node ad root
Installed pm2 globally as root
Post deploy commands are executed with sudo

I can see the app list showing on the terminal the deploy is executed but as soon as I log into the server and gain sudo privilegies Y can not see any app on the list.

@ghost
Copy link

ghost commented Oct 15, 2016

You likely launched your apps with a different PM2_HOME location.

Check to see where you have pm2 daemons running:

$ sudo ps aux | grep pm2

Chances are you have more than one, e.g.:

PM2 v2.0.18: God Daemon (/etc/.pm2)
PM2 v2.0.18: God Daemon (/home/root/.pm2)

The daemon that is running your applications will have .pid files in PM2_HOME/pids. Find out which one that is (probably /etc/.pm2/pids).

Then set the PM2_HOME variable and try again:

$ sudo PM2_HOME=/etc/.pm2 pm2 list

You'll probably want to relocate your apps to run from a PM2_HOME other than /etc/.pm2

@FaShapouri
Copy link

I have a problem with PM2 when running my app; As I am new node developer may my steps to run app looks funny :)
I follow below steps to run my app:

After uploading code to server I use pm2 start app.js -n "appname" to run project;
By pm2 list I could see information of project also after logout and log in to server and for some days

BUT the main problem is long time running! My project stops after some days running (about 4 days)
Why it stops? (no exception has been logged) and How can I prevent project to stop running;
In other way can I run project just after stopping?

@vmarchaud
Copy link
Contributor

@FaShapouri PM2 might run out of memory and somethings like this, could you check ~/.pm2/pm2.log for errors ?

@FaShapouri
Copy link

@vmarchaud Sorry I have just seen your answer, I got the permission denied when try ~/.pm2/pm2.log command. Is it unusual?

@vmarchaud
Copy link
Contributor

@FaShapouri Shouldn't be the case, that mean that your daemon is launched with another user (root in this case) and you don't have access to his log (so you can't access it too), try to fix that.

@FaShapouri
Copy link

@vmarchaud I have two users to login on server and my current user is not limited also I run pm2 by this user; OK I found at first step I need to have this log; I try to get it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants