[Backgroundrb-devel] How to keep from generating more than one worker?

刘昊 leomayleomay at gmail.com
Sun Aug 10 09:31:48 EDT 2008


2008/8/10 hemant <gethemant at gmail.com>

> On 8/10/08, 刘昊 <leomayleomay at gmail.com> wrote:
> >
> >
> > Thank you for your reply.
>
> Please, keep the converation on the mailing list. Lots of folks, try
> to search archives for similar questions and hence could be useful to
> them.
>
> >
> > I tried to create a new worker and assign a worker key to it, following
> is
> > what I did in ./script/console:
> >
> > >> MiddleMan.new_worker(:worker => :hello_worker,:worker_key => "boy")
> >  => nil
> > >> MiddleMan.worker(:hello_worker).worker_info
> > => {:status=>:stopped, :worker=>:hello_worker, :worker_key=>nil}
>
> When, you say:
> MiddleMan.worker(:hello_worker).worker_info
>
> you are asking worker_info for worker "hello_worker" which is running
> without any worker_key and hence result is expected. Try:
>
> MiddleMan.all_worker_info
>
>
>
>
>
> --
> Let them talk of their oriental summer climes of everlasting
> conservatories; give me the privilege of making my own summer with my
> own coals.
>
> http://gnufied.org
>

oops, sorry, I wrongly chose 'Reply' but 'Reply all'.

Two things:
1. How come "hello_worker" doesn't have a worker_key? I assigned "boy" as
its worker_key.

2. Can I use worker_key to identify the sole worker in my rails app? say,
can I use the following code to keep only one worker working in my app?
  unless MiddleMan.worker(:alert_worker, :alerter)
    MiddleMan.new_worker(:worker => :alert_worker, :worker_key => :alerter)
  end


Thank you,
All the best,
Hao Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20080810/dff25f4e/attachment.html>


More information about the Backgroundrb-devel mailing list