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].
For more options, visit this group at 
http://groups.google.com/group/beanstalk-talk?hl=.


Reply via email to