Running Mongrel on startup


I have a mongrel server running, but it stops whenever i reboot my

Is there a way of starting the mongrel server on bootup?


I use this one in my local startup script:

mongrel_cluster comes with a init script which works well. On my
Fedora/Red Hat/CentOS systems, the script is found at

Now if I could find out a way to also get 'script/backgroundrb start' to
automatically run as user, that would be nice.


i’ve used Monit for that.

my mongrel configuration:

check process mongrel_8001

with pidfile /tmp/mongrel/
start program = “/usr/bin/mongrel_rails cluster::start -C <RAILS_ROOT>/config/mongrel_cluster.production.yml --clean --only 8001”
stop program = “/usr/bin/mongrel_rails cluster::stop -C <RAILS_ROOT>/config/mongrel_cluster.production.yml --clean --only 8001”

if totalmem is greater than 80.0 MB for 4 cycles then restart
if cpu is greater than 50% for 2 cycles then alert
if cpu is greater than 80% for 4 cycles then restart
if loadavg(5min) greater than 10 for 8 cycles then restart

if 20 restarts within 20 cycles then timeout
if failed port 8001 protocol http with timeout 60 seconds then restart

and my backgroundrb configuration:

check process backgroundrb
with pidfile /tmp/
start program = "/bin/su -c ‘cd <RAILS_ROOT> && RAILS_ENV=production script/backgroundrb start’ "
stop program = "/bin/su -c ‘cd <RAILS_ROOT> && RAILS_ENV=production script/backgroundrb stop && sleep 3 && pkill -9 -f backgroundrb && rm /tmp/’ "

if cpu > 60% for 2 cycles then alert
if cpu > 90% for 5 cycles then restart

after that, run "sudo /etc/init.d/monitrc start all -g "

Felipe Mesquita

I'm running Ubuntu

All I wanted was a script that, when the server restarted, deleted the
PID file and could be restarted automatically.

I'll take a look around at the examples you've given me