Looks like the mongrel_rails command in mongrel 1.1 still does not fix
(or include an option) the issue of stale pid files. mongrel_rails
will just exit if a pid exists without first checking if anything is
actually running. You can use this script to patch up
mongrel_rails…
#===== patch mongrel
cd /usr/lib/ruby/gems/1.8/gems/mongrel-1.1/bin/
cp mongrel_rails mongrel_rails.orig
patch -p0 << ‘EOF’
— mongrel_rails 2007-05-08 11:18:32.000000000 -0500
+++ mongrel_rails.new 2007-05-08 11:18:32.000000000 -0500
@@ -83,10 +83,20 @@
config = Mongrel::Rails::RailsConfigurator.new(settings) do
if defaults[:daemon]
if File.exist? defaults[:pid_file]
-
log "!!! PID file #{defaults[:pid_file]} already exists.
Mongrel could be running already. Check your #{defaults[:log_file]}
for errors."
-
log "!!! Exiting with error. You must stop mongrel and
clear the .pid before I’ll attempt a start."
-
exit 1
-
pid = File.new(defaults[:pid_file]).readline
-
if `ps --pid #{pid} --no-headers`.length > 0
-
log "!!! PID file #{defaults[:pid_file]} already
exists and the process id referenced is running. This mongrel is
probably already running. #{defaults[:log_file]} for errors.
EXITING."
-
exit 1
-
else
-
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])
-
end end
+# if File.exist? defaults[:pid_file]
+# log “!!! PID file #{defaults[:pid_file]} already
exists. Mongrel could be running already. Check your
#{defaults[:log_file]} for errors.”
+# log “!!! Exiting with error. You must stop mongrel and
clear the .pid before I’ll attempt a start.”
+# exit 1
+# end
daemonize
log "Daemonized, any open files are closed. Look at
#{defaults[:pid_file]} and #{defaults[:log_file]} for info."
EOF