Ruby on Rails - restarting mongrel

Whenever I reboot my system, I have to hand restart my mongrel clusters. I don't like this, this is hardly robust, and there ought to be a better way. Nonetheless, this is the state of things as of late 2010 on my system. If I don't pay attention to this, my rails applications do not come up by themselves after a reboot, which can be very bad.

After a reboot, and not just after an abnormal shutdown there are some PID files in /xx/rails/myapp/tmp/pids that provide PID's for mongrel servers that no longer exist. The hassle is that as long as these PID files exist, I am unable to restart my mongrel clusters.

I must track down these PID files, delete them, then issue the command:

service mongrel_cluster restart
Or another twist, if I delete the PID files by mistake when there really is a server running, then I need to track down the processes and kill them (which is easier frankly) or the mongrel maintenance script refuses to stop or start them.

The game for me, given the two rails applications I run on my server, is:

cd /xx/rails/micros/tmp/pids
rm *.pid
cd /xx/rails/tara/tmp/pids
rm *.pid
service mongrel_cluster restart

Feedback? Questions? Drop me a line!

Ruby on Rails notes / [email protected]