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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Guterl
2007-Nov-07 00:33 UTC
Re: bin/mongrel_rails to make it play nice with monit
On Nov 6, 2007 5:33 PM, uncle <aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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... > <snip> >Maybe it''s specific to mongrel_cluster, but I thought there was a new --clean option to take care of this. Michael Guterl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---