I have used this "unclean" method in production environments, and it works
like a charm.  One thing to keep notice of, if you are using beanstalk ruby
client (1.0.2) and your reserve with timeout, there is a leak that will
cause the client to keep creating new connection without closing old ones
every time it "reserves" and does not find a message.

Check this thread for an explanation of the problem:
http://groups.google.com/group/beanstalk-talk/browse_thread/thread/8385631228bf924/2680fb21718972e4?lnk=gst&q=faisal#2680fb21718972e4

And this thread for a solution (p.s: you'll have to patch the gem yourself):
http://groups.google.com/group/beanstalk-talk/browse_thread/thread/e8e1176c6dfefc80

On Sat, Nov 21, 2009 at 2:05 AM, gonzoprosperity <[email protected]> wrote:

> We have a Rails based app so we use the beanstalk-ruby client.
>
> I am wondering how people have their background workers monitored and
> controlled. We usually use God to monitor jobs but I cannot seem to
> get it to play nice with the workers.
>
> Our worker code is basically:
>
> @stop = false
> trap('TERM') { @stop = true }
> loop do
>  break if @stop
>  job = queue.reserve
>  ... operate on job...
>  job.delete
> end
>
>
> Since +reserve+ blocks its possible that you will just sit there
> waiting for jobs, thus if a SIGTERM is sent to the script then it wont
> actually quit until a job comes along and gets processed - which for
> us can be very unpredictable.
>
> My next thought was to specify a reserve timeout
>
>  job = queue.reserve(20) # seconds
>
> So that at least every 20 seconds there will be a loop iteration any
> SIGTERM sent in the interim can be caught and handled.
>
> But this just doesnt seem very clean.
>
> Whats the methodology that others have successfully employed?
>
> Thanks
> /Cody
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "beanstalk-talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<beanstalk-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/beanstalk-talk?hl=.
>
>
>


-- 
Al-Faisal El-Dajani
10/6

--

You received this message because you are subscribed to the Google Groups 
"beanstalk-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/beanstalk-talk?hl=.


Reply via email to