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

pm2 startup error on Centos 6.3 #57

Closed
markkevans opened this issue Jul 20, 2013 · 23 comments
Closed

pm2 startup error on Centos 6.3 #57

markkevans opened this issue Jul 20, 2013 · 23 comments

Comments

@markkevans
Copy link
Contributor

When running pm2 startup the following error is generated

pm2 startup
{ [Error: Command failed: /bin/sh: update-rc.d: command not found
] killed: false, code: 127, signal: null }

I guess there are 2 possible solutions

  1. Check Platform OS and if not debian / ubuntu don't attempt to run update-rc.d
  2. Check if update-rc.d script exists on the platform before attempting to run it

Any thoughts on the best way to solve this?

@soyuka
Copy link
Collaborator

soyuka commented Jul 20, 2013

According to this stackoverflow post I think that the OS checking part is a bit fastidious and checking the update-rc.d script just take 1 line of code so I'd vote for the second way of doing this :).

@fakewaffle
Copy link

I get the same error.

@Unitech
Copy link
Owner

Unitech commented Jul 29, 2013

Is there an update-rc.d tool like in CentOS ?

@markkevans
Copy link
Contributor Author

Looks like chkconfig might be the centos version http://linuxcommand.org/man_pages/chkconfig8.html

@mani95lisa
Copy link

I want this too, please!

@purepear
Copy link

On CentOS 6.4 i had to add some config at the begining of the file...

# chkconfig: 2345 98 02

It's means booting at levels 2,3,4 and 5 and the other two numbers (98 02) are the priorities at boot and shutdown time i think

#!/bin/bash
# chkconfig: 2345 98 02
#
# description: PM2 next gen process manager for Node.js
# processname: pm2
#
### BEGIN INIT INFO
# Provides:          pm2
....

Unitech added a commit that referenced this issue Aug 19, 2013
Unitech added a commit that referenced this issue Aug 19, 2013
@Unitech
Copy link
Owner

Unitech commented Aug 19, 2013

I think it's okay now, someone can tell me if it works on CentOS ?

To try the startup script :

$ npm install git://github.com/Unitech/pm2.git -g
$ pm2 startup centos

Thanks for feedback

@fakewaffle
Copy link

$ pm2 startup centos

Launching daemon
{ online: true, success: true, pid: 22761 }
⌬ PM2 You have to run this command as root
⌬ PM2 Execute the following command :
⌬ PM2 sudo env PATH=$PATH:/usr/bin pm2 startup

Is that what you expected?

@Unitech
Copy link
Owner

Unitech commented Aug 19, 2013

Yes, can you try now the command

sudo env PATH=$PATH:/usr/bin pm2 startup centos

@ecoad
Copy link

ecoad commented Aug 20, 2013

I have a Linux AMI based on Redhat. Would you be able to get this script working for Redhat too?

@Unitech
Copy link
Owner

Unitech commented Sep 21, 2013

@ecoad give me more clues about how to start a process at startup on Redhat with V init scripts, thanks

@mani95lisa
Copy link

@Unitech I got the Empty error , please have a look. My server is CentOS release 6.4 (Final).

image

Thanks!

@sudowork
Copy link
Contributor

@mani95lisa
Your AMI probably uses chkconfig (like CentOS). From the looks of it, it probably succeeded. The init script would be in /etc/init.d/pm2-init.sh.

@HowtoGhost
Copy link

I have the same problem as @mani95lisa. Gives no feedback, does create the init script, but nothing starts on startup

@sudowork
Copy link
Contributor

Can you copy paste the output of chkconfig --list?

@HowtoGhost
Copy link

https://gist.github.com/howtoinstallghost/8367225

also has the error from the pm2 error log

Thanks,
David

@mani95lisa
Copy link

I have to use forever to make it right, hope this problem could be resolved.

@Unitech
Copy link
Owner

Unitech commented Jan 13, 2014

At least pm2 has generated the init script.

Here is the line doing the chkconfig : https://github.com/Unitech/pm2/blob/master/lib/CLI.js#L204

If someone know the right command line to set a script at startup on CentOS, please share (:

@Unitech
Copy link
Owner

Unitech commented Jan 14, 2014

This worked for me on CentOS6.4

$ crontab -e
@reboot /root/.nvm/v0.11.9/bin/node /root/.nvm/v0.11.9/bin/pm2 resurrect
*/5 * * * * /root/.nvm/v0.11.9/bin/node /root/.nvm/v0.11.9/bin/pm2 dump

Just replace these values by what is written on the /etc/init.d/pm2-init.sh (node and pm2)

Tell me if it worked for you also

@Unitech Unitech reopened this Jan 14, 2014
@aboutte
Copy link

aboutte commented Jan 18, 2014

@Unitech Your suggestion above works for me. I wanted to avoid using the cron to resurrect so I looked into why the init.d script wasnt working for me. I am running on the Amazon Linux AMI and the default init.d script was not starting my application. In the init.d script I removed the super function and all the calls to it and it started working for me.

Not sure if this is a bug with the init.d script but it worked for me.

@Unitech
Copy link
Owner

Unitech commented Jan 30, 2014

I've written a dedicated startup script for centos :

https://github.com/Unitech/pm2/blob/master/lib/scripts/pm2-init-centos.sh

It uses su instead of sudo and creates the lockfile to call the init script on shutdown.

Available on pm2 0.7.2

$ chkconfig --del pm2-init.sh
$ pm2 dump
$ npm install pm2@latest
$ pm2 kill ; pm2 resurrect
$ pm2 startup centos

@Unitech Unitech closed this as completed Jan 30, 2014
@frankbecker
Copy link

I was able to run the startup command on an Oracle Linux machine, might have been Red Hat, even though I tried using redhat as a platform option.
pm2 startup centos

This worked beautifully, my pm2 processes restart when the server restarts.

@jshkurti
Copy link
Contributor

👍

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