users of monitoring systems may have noticed that mongrel can leave stale PID files behind, which prevents automated monitors from restarting mongrels that have been detected as dead via a port or process check, as mongrel's default behaviour is to exit upon the detection of a pre-existing PID file, whether there is in fact a process of that id running or not.
a fix, in /usr/local/lib/ruby/gems/1.8/gems/mongrel-x.x.x/bin/mongrel_rails:
if File.exist? defaults[:pid_file]
# mongrels that crash can leave stale PID files behind, and these
# should not stop mongrel from being restarted by monitors...
pid = File.new(defaults[:pid_file]).readline
unless `ps -ef | grep #{pid} | grep -v grep`.length > 0
# use "ps ax" for freebsd
log "!!! PID file #{defaults[:pid_file]} exists, but is stale, and will be deleted so that this mongrel can run."
File.delete(defaults[:pid_file])
else
log "!!! PID file #{defaults[:pid_file]} already exists and the process id referred to in it is running. This mongrel is probably already running. #{defaults[:log_file]} for errors. EXITING."
exit 1
end
end
there is a call to at_exit in mongrel, which should be cleaning these files up.. but is not.