PID problem with power outage

We have unique problem. We live in India where we have power outage for
at least 10-20 mins - once or twice a day. We run a small demo server
where I deploy “in progress” apps for my clients. We have been using and
evangalising RoR since 8-10 months now in our organisation.

I have mongrel configured to serve out the web apps and it dutifully
stops and starts during system shutdown/reboot. The problem is when I
have an unexpected power outage. (I know I should have a UPS/power
backup and I will be getting one soon but the problem still cannot be
ignored and a UPS is at best a temporary solution.)

When power is cut off to the server, the ‘mongrel.xxxport.pid’ files
remain in the respective log directories and prevent the mongrel servers
from starting up. I have to manually delete them and restart the
mongrels. Is there any way I can avoid manual intervention? (I could
write a script to delete the pids and put it in run level 3 but that is
pretty ugly.)

This problem does not exist with any other server -
apache/postfix/subversion… and I do not think it should exist with
mongrel either. Do let me know if I can help. I have done socket
programming in ‘C’ before and have really smart people with ruby
knowledge.

Thanks,
kc

http://textsnippets.com/posts/show/931

On Apr 1, 9:59 pm, kc [email protected] wrote:

When power is cut off to the server, the ‘mongrel.xxxport.pid’ files
remain in the respective log directories and prevent the mongrel servers
from starting up. I have to manually delete them and restart the
mongrels. Is there any way I can avoid manual intervention? (I could
write a script to delete the pids and put it in run level 3 but that is
pretty ugly.)

I’ve been running mongrel_cluster on Debian, and putting my .pid files
in /tmp. Debian empties out /tmp on reboot, so this has worked fine.
I should look in to what kind of housecleaning goes on with properly
putting .pid files in /var/run, but I haven’t.