Closed tademianhess closed 7 years ago
Can you give me the name of the image that you used to spawn this system ?
AMI ID: amzn-ami-hvm-2016.09.0.20161028-x86_64-gp2 (ami-b73b63a0) AMI Description: Amazon Linux AMI 2016.09.0.20161028 x86_64 HVM GP2
Spawned an instance 1 hour ago and reproduced the problem, we will publish a fix in the next hours.
Fixed. Please upgrade to PM2 2.2.2:
$ npm install pm2 -g
$ pm2 update
$ pm2 startup amazon
Thanks @Unitech. My issue was different, and your solution only partly solved it. The platform my company use is defined as "Linux" rather than "Amazon"
I hope the following might help some one in similar situation.
>>>> In-memory PM2 is out-of-date, do:
>>>> $ pm2 update
In memory PM2 version: 2.0.18
Local PM2 version: 2.2.2
After updating pm2 update
. The above warning message i get when accessing pm2 disappears, however running pm2 startup linux -u user --hp /home/app
still broke with
Error: Unknown platform / init system name
Changing this to something other than Linux, aka systemd
for Debian seems to have done the trick. reference
e.g. pm2 startup systemd -u user --hp /home/app
Don't try to put an plateform, just run pm2 startup
, pm2 will determine the system you use (Amazon linux use SystemV), we tested under a fresh vm instance on amazon and it works great for us.
@vmarchaud is this a correct way for setting up the auto startup in bash script?
export NODE_ENV=dev NODE_ENV=dev sudo -E pm2 start node/myApp/build/bin/www --name myApp sudo pm2 startup sudo pm2 save
@oleksiypavlenko If your aim is to setup is as root user, yes.
@vmarchaud it is indeed, thank you. I ran into a problem running application as a regular user with freezes when spawning pm2 daemon through script. When I changed all the pm2 to be running under sudo, it looked as if it resolved the problem.
This is how I ran it originally (led to issue with script freezing at the point when pm2 daemon was spawn):
NODE_ENV=dev pm2 start node/myApp/build/bin/www --name myApp sudo pm2 startup ubuntu -u username pm2 save
@oleksiypavlenko Could you try reproducing with DEBUG=pm2:*
at the beginning of all command you've done and paste the content in a gist ?
If reporting a bug, please use the following template.
Expected behaviour
After running 1)
pm2 startup
and specifying "amazon" as the platform, 2) starting nodejs apps,and 3) runningpm2 save
, all apps should restart after server reboot. ...Actual behaviour
When running
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup amazon -u ec2-user --hp /home/ec2-user
get error /usr/lib/node_modules/pm2/lib/API/Startup.js:214 throw new Error('Unknown platform / init system name'); When runpm2 startup
, system suggests specifying platform as 'rcd'. However, after running with that platform, runningpm2 save
, and rebooting, no apps restart. ...Steps to reproduce
Spin up new Amazon Linux server and install pm2 (v 2.2.1). Start nodejs apps. SSH to server as ec2-user
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup amazon -u ec2-user --hp /home/ec2-user
=> Results in error.Rerun with suggested platform of rcd: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup rcd -u ec2-user --hp /home/ec2-user`
Start all nodejs applications Run
pm2 save
Exit from shell Reboot server No apps restart ... ...Software versions used
PM2 Log output
Use the command:
tail --lines 50 ~/.pm2/pm2.log
2016-12-14 22:30:43: =============================================================================== 2016-12-14 22:30:43: --- New PM2 Daemon started ---------------------------------------------------- 2016-12-14 22:30:43: Time : Wed Dec 14 2016 22:30:43 GMT+0000 (UTC) 2016-12-14 22:30:43: PM2 version : 2.2.1 2016-12-14 22:30:43: Node.js version : 6.9.1 2016-12-14 22:30:43: Current arch : x64 2016-12-14 22:30:43: PM2 home : /home/ec2-user/.pm2 2016-12-14 22:30:43: PM2 PID file : /home/ec2-user/.pm2/pm2.pid 2016-12-14 22:30:43: RPC socket file : /home/ec2-user/.pm2/rpc.sock 2016-12-14 22:30:43: BUS socket file : /home/ec2-user/.pm2/pub.sock 2016-12-14 22:30:43: Application log path : /home/ec2-user/.pm2/logs 2016-12-14 22:30:43: Process dump file : /home/ec2-user/.pm2/dump.pm2 2016-12-14 22:30:43: Concurrent actions : 2 2016-12-14 22:30:43: SIGTERM timeout : 1600 2016-12-14 22:30:43: =============================================================================== 2016-12-14 22:30:50: [Watch] Start watching 0 2016-12-14 22:30:50: Starting execution sequence in -fork mode- for app name:oqc id:0 2016-12-14 22:30:50: App name:oqc id:0 online 2016-12-14 22:41:08: pm2 has been killed by signal, dumping process list before exit... 2016-12-14 22:41:08: Deleting process 0 2016-12-14 22:41:08: Stopping app:oqc id:0 2016-12-14 22:41:08: App [oqc] with id [0] and pid [2785], exited with code [0] via signal [SIGTERM] 2016-12-14 22:41:08: pid=2785 msg=process killed 2016-12-14 22:41:08: [PM2] Exited peacefullyDump.pm2 looks like this:
cf CONTRIBUTING.md for more informations