[英]AWS EC2, pm2 : Cannot see pm2 running list
I'm using Amazon Linux AMI 2017.03.1 (HVM), SSD Volume Type. 我正在使用Amazon Linux AMI 2017.03.1(HVM),SSD卷类型。
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. 我通过以下方式安装了node.js,npm,因为我想全局安装,如果我没有全局安装pm2,当我配置EC2 bootstrapping启动pm2命令时,它不起作用。
After that I created my own AMI image. 之后我创建了自己的AMI图像。
### 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. 当我通过自己的AMI创建新的EC2实例时,这是我在'高级详细信息'中的用户数据文本。
### 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. 所以当我使用上面的配置启动新的EC2实例时,pm2命令正在运行,但我看不到正在运行的pm2列表。
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应用程序的信息!
### /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 但我看不到运行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
Does anyone who know this issue and solution??? 有谁知道这个问题和解决方案??? Thanks.
谢谢。
I changed several commands in EC2 User-Data like 我改变了EC2用户数据中的几个命令
#!/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 -i pm2 list
. 我现在可以看到pm2列表输入
sudo -i pm2 list
。 and shown empty list when i just typed pm2 list
. 当我输入
pm2 list
时显示空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
. 这是
/root/.pm2/dump.pm2
上下文。
https://github.com/geoseong/Node.js-Test/blob/master/pm2/dump_pm2_sudo_170904 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. 希望对那些遇到这样问题的人有所帮助。
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.