aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 20:21 UTC
mongrel PID files and reboot
I have followed the instructions on the mongrel website, and now have mongrel_cluster running my apps at boot time, works great. Now, if the server goes down ungracefully, the mongrel processes do not start up on reboot because the mongrel PID files are still hanging around. I have boot job that cleans those up now, but is there a "GOOD" way to handle this ??? -- Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well, that''s how I''ve handled it... I''d also like to know if anyone has any better methods. On 4/23/07, aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I have followed the instructions on the mongrel website, and now have > mongrel_cluster running my apps at boot time, works great. > > Now, if the server goes down ungracefully, the mongrel processes do > not start up on reboot because the mongrel PID files are still hanging > around. > > I have boot job that cleans those up now, but is there a "GOOD" way to > handle this ??? > > -- Thanks > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 20:36 UTC
Re: mongrel PID files and reboot
Actually, I just found this, its looks cleaner than what I have... http://textsnippets.com/posts/show/931 Basically just a change to the mongrel_rails script to delete PID files that reference a process that is not actually running...sounds like a good thing to be included to me. On Apr 23, 3:24 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well, that''s how I''ve handled it... I''d also like to know if anyone has any > better methods. > > On 4/23/07, akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I have followed the instructions on the mongrel website, and now have > > mongrel_cluster running my apps at boot time, works great. > > > Now, if the server goes down ungracefully, the mongrel processes do > > not start up on reboot because the mongrel PID files are still hanging > > around. > > > I have boot job that cleans those up now, but is there a "GOOD" way to > > handle this ??? > > > -- Thanks--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 20:51 UTC
Re: mongrel PID files and reboot
this is what I am using now (changed in mongrel-1.0.1/bin/ mongrel_rails if File.exist? defaults[:pid_file] #===== new stuff pid = File.new(defaults[:pid_file]).readline if `ps --pid #{pid} --no-headers`.length > 0 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 #===== old stuff #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 On Apr 23, 3:36 pm, "akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Actually, I just found this, its looks cleaner than what I have... > > http://textsnippets.com/posts/show/931 > > Basically just a change to the mongrel_rails script to delete PID > files that reference a process that is not actually running...sounds > like a good thing to be included to me. > > On Apr 23, 3:24 pm, "Brian Hogan" <bpho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Well, that''s how I''ve handled it... I''d also like to know if anyone has any > > better methods. > > > On 4/23/07, akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <akt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have followed the instructions on the mongrel website, and now have > > > mongrel_cluster running my apps at boot time, works great. > > > > Now, if the server goes down ungracefully, the mongrel processes do > > > not start up on reboot because the mongrel PID files are still hanging > > > around. > > > > I have boot job that cleans those up now, but is there a "GOOD" way to > > > handle this ??? > > > > -- Thanks--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-23 21:07 UTC
Re: mongrel PID files and reboot
oops, this is actually what I am running now (again patched into /usr/ lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails) if File.exist? defaults[:pid_file] #===== new stuff 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 #===== old stuff #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." end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Found this thread searching the archives, after running into this same problem. Anyone know why this hasn''t been added to mongrel_cluster trunk yet? Very annoying. Or maybe it has been, but just wasn''t in the distro I got? Problem is if your server/mongrels dies ungracefully, then /etc/init.d/mongrel_cluster won''t succesfully start up your mongrels again, since there are stale pids. aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> oops, this is actually what I am running now (again patched into /usr/ > lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails) > > > > if File.exist? defaults[:pid_file] > #===== new stuff > 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 > #===== old stuff > #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." > end-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Okay, I found that, at least in the newest versions of mongrel_cluster, you can supply a --clean argument to have mongrel_cluster delete any leftover pids. Anyone know how I get this to happen on boot? Right now I''m just linking /etc/init.d/mongrel_cluster to mongrel_cluster_gem/resources/mongrel_cluster . Any way short of hacking the source (meaning it will break next time I update) to get --clean to be the default for mongrel_cluster start? Jonathan Jonathan Rochkind wrote:> Found this thread searching the archives, after running into this same > problem. Anyone know why this hasn''t been added to mongrel_cluster trunk > yet? Very annoying. Or maybe it has been, but just wasn''t in the distro > I got? > > Problem is if your server/mongrels dies ungracefully, then > /etc/init.d/mongrel_cluster won''t succesfully start up your mongrels > again, since there are stale pids. > > aktxyz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> oops, this is actually what I am running now (again patched into /usr/ >> lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails) >> >> >> >> if File.exist? defaults[:pid_file] >> #===== new stuff >> 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 >> #===== old stuff >> #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." >> end-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---