Todd Tyree
2008-Feb-22 14:53 UTC
[Backgroundrb-devel] ask_status returning ''running'' even when the process has been killed
Just wondering if anyone else was seeing behaviour like this? I''ve got a long running worker used to allow a cluster of mongrels to talk to an xmpp server over a single connection using xmpp4r. I''ve seen the worker die a couple of times, so I set up a worker_alive? method that looks like this: def worker_alive? MiddleMan.ask_status(:worker => :xmpp_worker) == ''Running.'' end The problem I''m having is that ask_status always returns ''Running'', even if the worker is dead and gone, so I can never get it to restart this way. I''ve confirmed the worker is dead via top, ps and the xmpp admin console. I''ve had a brief look at the ask_status code, but don''t see anything obvious. MiddleMan#query_all_workers returns the correct information, however. I''m running r315 of BDrb on OSX with 2.0.2. Any thoughts or suggestions would be appreciated. Cheers, Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080222/0790c0ce/attachment.html
Ryan Leavengood
2008-Feb-22 15:16 UTC
[Backgroundrb-devel] ask_status returning ''running'' even when the process has been killed
On Fri, Feb 22, 2008 at 9:53 AM, Todd Tyree <todd at snappl.co.uk> wrote:> > The problem I''m having is that ask_status always returns ''Running'', even if > the worker is dead and gone, so I can never get it to restart this way. > I''ve confirmed the worker is dead via top, ps and the xmpp admin console.The master worker keeps the status for workers even after they are dead, because in most cases it is useful to be able to query a worker''s status once it has died. This is a little clumsy, but you can write your method like this instead: def worker_alive? !(MiddleMan.all_worker_info.detect{|worker| worker[:status] =:running && worker[:worker] == :xmpp_worker }.nil?) end As far as I can see all_worker_info only returns currently running workers, so probably the check for :status == :running is redundant. Ryan