We are using a AWS CodeDeploy and PM2 version: '^0.12.14' to manage our web application, but we got a empty list after hitting pm2 list although that node application is started successfully and PM2 is running currently on the server, Also PM2 logs are working fine for both the application logs and PM2 logs ~/.pm2/pm2.log as following:
Starting execution sequence in -cluster mode- for app name:app id:0
App name:app id:0 online
but when we tried to show the application app details it shows that there is no app with this name or even id pm2 show app, it gives us [PM2][WARN] app doesn't exist.
We don't know what's exactly the problem, could you please help us?
are you sure the app is running under the same user from which you are trying to do a PM2 list?
sudo ps aux | grep node
Yes it works fine and sudo ps aux | grep node shows the start command app.js to start the app and it works fine
Just to confirm...
Is the result of whoami
The same as the result of sudo ps aux | grep node | awk '{ print $1 }'?
Yes, it's the same .. we are using the same user to deploy our application then start the pm2
+1
Try a fresh start (kill everything pkill -9 PM2; pkill -9 node; npm i -g pm2@latest).
+1 I started to face the same problem, I do not know when exactly(which version) it started to show up since PM2 was working perfectly before.
@jshkurti I tried not killing PM2, even starting a new EC2 instance and starting over, same happens.
My package.json file always installs the latest version "pm2": "^0.12.14"
+1
This only happens when we are launching our apps programatically. When launching them via the CLI, they show up well with pm2 list
@bcldvd: Yeah exactly, but do you have any suggestions ?!
@mohamedazouz, Nope :(
We were hoping that there would be a workaround or bug fix by now :/
Edit : Also this affects only our unix-based machines. Process shows up fine on windows
+1
pm2 -v 0.12.15
uname -r 3.13.0-43-generic
lsb_release -d Ubuntu 14.04.1 LTS
Additional info:
ยท we notice that use to happen after some of the pm2 instances fatally breaks. Logs available under request.
ยท when happen, it also breaks the dumped set up (which is really annoying)
Looks like all of you are talking about PM2 0.12.x, please upgrade to latest PM2.
If this happen with the new PM2 version, HTOP screenshot showing PM2 processes is welcome
Moving to 0.15 @Unitech
Anyway, any clue why is happening? Is there a reason to believe that this won't happen with the latest version?
@edravis +1
we are going to move to 0.15 and will check if it's still happened but @Unitech do you know why this was happening and how the new version solved it?
Hey @Unitech after a simple pm2 update I'm still in 0.12.5
also I've tried npm update pm2
ans also npm i -g [email protected]
also uninstalling and `npm i -g pm2``
any suggestion?
I also have an empty list on heroku.
top - 21:14:18 up 48 days, 6 min, 0 users, load average: 3.08, 3.29, 3.55
Tasks: 4 total, 1 running, 3 sleeping, 0 stopped, 0 zombie
%Cpu(s): 27.7 us, 8.7 sy, 0.0 ni, 62.2 id, 0.0 wa, 0.0 hi, 0.9 si, 0.4 st
KiB Mem: 62916392 total, 58525256 used, 4391136 free, 2916644 buffers
KiB Swap: 63963132 total, 974036 used, 62989096 free. 21192888 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 nobody 20 0 21096 1500 1308 S 0.0 0.0 0:00.00 ps-run
3 u52372 20 0 18156 1960 1484 S 0.0 0.0 0:00.01 bash
15 u52372 20 0 941184 28952 8108 S 0.0 0.0 0:00.48 PM2 v0.15.10: G
72 u52372 20 0 19872 1360 1016 R 0.0 0.0 0:00.06 top
~/.pm2 $ whoami
u52372
~/.pm2 $ pm2 -v
0.15.10
~/.pm2 $
+1
I appear to have the same (or similar) issue. I have several apps configured in PM2. One of them doesn't autorestart. When running it by entering pm2 start myapp it works fine. But when running it via the crontab I get [PM2][ERROR] script not found : /myapp. My usecase is a cron job that utilizes PM2's clustering features to run on multiple cores.
Researching the problem, I added * * * * * root pm2 list >> test.txt to the crontab which entered empty lists into the file every minute, despite the list having many apps when shown manually (with the root user).
I've noticed PM2 keeps separate application lists per user. By which parameters does PM2 keep these lists? Where does it keep the lists?
/usr/local/bin/pm2)I'm still experiencing this issue with 1.0.0
+1
I am also using AWS CodeDeploy with PM2, during AfterInstall hook, my sh does:
whoami
# root
pm2 delete all
pm2 start index.js
# [PM2] Starting index.js in fork_mode (1 instance)
And in my /etc/.pm2/pm2.log, it says:
2016-02-26 04:31:43: Starting execution sequence in -fork mode- for app name:index id:0
2016-02-26 04:31:43: App name:index id:0 online
everything seems alright.
But when I ssh to my ec2 instance, and run pm2 list as root,
App list shows nothing.
and ps aux | grep node
root 1980 0.0 0.9 954980 40276 ? Ssl 04:31 0:02 node /opt/codedeploy-agent/deployment-root/d2699bd2-255e-4
I can see node running.
Am I doing anything wrong?
Hope this would help!
pm2 -v 1.0.1
node -v v4.3.1
@ddhp you are not doing anything wrong but i guess version is the factor now
As our PM2 version ^0.12.14, will check to upgrade our pm2 to yours and see if it will work fine or not.
@mohamedazouz Tks for your info! Do you mean it's working fine with v0.12.14?
b/c I downgrade pm2 to v0.12.14, situation is still the same, empty list shown in pm2 list.
node app is running like a charm, although I can't monitor it with pm2 commands :s
@ddhp not it was working on this version for PM2, I guess we all have the same issue with different versions, all we can do is to upgrade can solve this issue or anyone have another solution.
Experiencing the same in 1.0.1
+1
+1
I'm wondering is there any way to make pm2 task share with users? e.g. there are two people working for deploy and they use different user.
+1
+1
+1 having the same problem. Users are the same.
+1 Seeing same issue in 1.1.2
+1
Update to PM2 development:
$ npm install Unitech/pm2#development -g
$ pm2 update
And show me output of sudo ps aux | grep node and whoami
The main hypothesis is that there are two PM2s running
+1 same issue with version 1.1.3
I had the same problem with pm2 0.12.x and i thought an update should fix that but unfortunately not, I got the same issue using the version 1.1.3
Then i start trying to reproduce this using docker.
I created a docker container with ssh config and run this as an ssh server where i deployed my application. I couldn't reproduce the issue.
Comparing the environment variables of both servers (my live server and the server running in docker), i found that the only difference was the PM2_HOME variable, when i unset the PM2_HOME variable on my live server, i could list again my running applications using pm2 list
I think the PM2 home folder is by default ~/.pm2 my PM2_HOME was the home folder of the user.
So my solution was either unsetting the env variable or setting it to the right folder, in my case was this /home/username/.pm2
@Unitech could you please check and confirm this?
Here is an example Dockerfile with node, npm & pm2 where you can deploy your app and compare to you server configs:
FROM node:latest
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
RUN npm install -g [email protected]
EXPOSE 22
I'm running into this issue with Puppet. The process is running, I can see the .pid file that was created with the process ID but I can't kill the process and it does not show up in the pm2 list.
What is the solution other than to rely only on the ps list rather than on pm2?
Because the CLI connect to the daemon, which is by default connecting to ~/.pm2/rpc.sock so it depend on with which user you are running the command.
You can set PM2_HOME to tell pm2 to find the rpc.sock file in a specific folder.
+1
I'm using Amazon Linux AMI 2017.03.1 (HVM), SSD Volume Type.
And I installed node.js, npm via the way like this below because I want to install globally and if I don't install pm2 globally, it doesn't work when I configure EC2 bootstrapping launching pm2 command.
After that I created my own AMI image.
### node.js, npm install ###
$ sudo su
$ curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
$ yum -y install nodejs
### pm2 install ###
$ npm install pm2 -g
and here is my user-data text at 'Advanced Details' when i create new EC2 instance via my own AMIs.
### user-data ###
#!/bin/bash
cd /home/ec2-user/Node.js-Test
sudo git pull origin master
export PM2_HOME=/home/ec2-user/
sudo env PATH=$PATH:/usr/bin/ pm2 startup systemv -u ec2-user --hp /home/ec2-user
su ec2-user
pm2 start /home/ec2-user/Node.js-Test/app.js
pm2 save
so when I launch new EC2 instance with this configuration above, pm2 command is working but I cannot see the running pm2 list.
When I checked the log file /var/log/cloud-init-output.log, it has info of running pm2 application!
### /var/log/cloud-init-output.log ###
[PM2] Spawning PM2 daemon with pm2_home=/home/ec2-user/
[PM2] PM2 Successfully daemonized
[PM2] Starting /home/ec2-user/Node.js-Test/app.js in fork_mode (1 instance)
[PM2] Done.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ app โ 0 โ fork โ 2677 โ online โ 0 โ 0s โ 99% โ 15.4 MB โ root โ disabled โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Use 'pm2 show <id|name>' to get more details about an app
but I cannot see that running pm2 list @ec2-user, @root
### in terminal EC2 instance ###
[ec2-user@ip-172-31-10-85 ~]$ 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
[ec2-user@ip-172-31-10-85 ~]$ sudo su
[root@ip-172-31-10-85 ec2-user]# 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
so I want to see running pm2 list at any account in my EC2 instance...
facing the same issue with node 2.7.2,
starting pm2 in applicationStart hook, the application starts perfectly. But when I SSH my instance and check PM2, the application is not listed there for the same user. Need suggestions to fix this.
Here is my solved case.
but I use sudo command.
I changed several commands in EC2 User-Data like
#!/bin/bash
cd /home/ec2-user/Node.js-Test
sudo git pull origin master
sudo pkill -f PM2
sudo pm2 start /home/ec2-user/Node.js-Test/app.js
sudo pm2 startup
sudo pm2 save
and I can see pm2 list now typing sudo pm2 list. and shown empty list when i just typed pm2 list.
[ec2-user@ip-172-31-14-68 .pm2]$ sudo pm2 list
โโโโโโโโโโโโฌโโโโโฌโโโโโโโฌโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโโโฌโโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโ
โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ
โโโโโโโโโโโโผโโโโโผโโโโโโโผโโโโโโโผโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโผโโโโโโผโโโโโโโโโโโโผโโโโโโโผโโโโโโโโโโโค
โ app โ 0 โ fork โ 2458 โ online โ 0 โ 11m โ 0% โ 29.3 MB โ root โ disabled โ
โโโโโโโโโโโโดโโโโโดโโโโโโโดโโโโโโโดโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโดโโโโโโดโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโ
And here is context of /root/.pm2/dump.pm2.
https://github.com/geoseong/Node.js-Test/blob/master/pm2/dump_pm2_sudo_170904
hope it help for those who got the problem like this.
Here is my solved case.
but I usesudocommand.I changed several commands in EC2 User-Data like
#!/bin/bash cd /home/ec2-user/Node.js-Test sudo git pull origin master sudo pkill -f PM2 sudo pm2 start /home/ec2-user/Node.js-Test/app.js sudo pm2 startup sudo pm2 saveand I can see pm2 list now typing sudo pm2 list. and shown empty list when i just typed pm2 list.
[ec2-user@ip-172-31-14-68 .pm2]$ sudo pm2 list โโโโโโโโโโโโฌโโโโโฌโโโโโโโฌโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโโโฌโโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโ โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ โโโโโโโโโโโโผโโโโโผโโโโโโโผโโโโโโโผโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโผโโโโโโผโโโโโโโโโโโโผโโโโโโโผโโโโโโโโโโโค โ app โ 0 โ fork โ 2458 โ online โ 0 โ 11m โ 0% โ 29.3 MB โ root โ disabled โ โโโโโโโโโโโโดโโโโโดโโโโโโโดโโโโโโโดโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโดโโโโโโดโโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโAnd here is context of /root/.pm2/dump.pm2.
https://github.com/geoseong/Node.js-Test/blob/master/pm2/dump_pm2_sudo_170904
hope it help for those who got the problem like this.
@geoseong Are u Jesus? Thank you so much for the answer. This saved my day
Even after deployment as a root I had to add sudo to see app list. sudo pm2 status
I have the same issue. The problem is pm2 is run by root user and you probably ssh to your instance with another user. My solution is to get into the root shell by
sudo -i
pm2 list
and then you will see the service you host on the instance
```shell
export PM2_HOME='/etc/.pm2'
pm2 start process.yml
pm2 list
Most helpful comment
are you sure the app is running under the same user from which you are trying to do a PM2 list?
sudo ps aux | grep node