Getting shell script to run as a daemon on CentOS?

Solution 1:

I think your problem is in /srv/rhodecode/start.sh. It is currently starting paster as a separate background process and then immediately exiting. This poses a problem for your init script, which expects start.sh to itself be the long-running daemon process to be managed.

Thus, try changing the last line of /srv/rhodecode/start.sh to read as follows:

exec paster serve production.ini 1> debug.log 2> error.log

Using exec makes start.sh become paster, which is then daemonized by the daemon command in the init script.