2

I have some jobs that run longer than 119 seconds during peak times and I keep getting the stalker error below when it does. I am using stalker, beanstalkd and clockwork for my background processing. Where/how can I change the timeout settings?

Exception Stalker::JobTimeout -> find.products hit 119s timeout
   /home/blake/.rvm/gems/ruby-1.9.2-p180/gems/stalker-0.9.0/lib/stalker.rb:86:in
Jamie Hutton
  • 260
  • 3
  • 13
blakecash
  • 117
  • 1
  • 7

1 Answers1

3

Stalker.enqueue takes 3 options: job name string, arguments hash, options hash.

The options hash can take the key/value pair :ttr => timeout_in_seconds, which, as you probably can guess, sets the number of seconds Stalker will allow before it raises the JobTimeout Exception.

E.g. if you have some crazy calculation you expect to take an hour:

#job code
job 'crazy.calculation' do |args|
  args['x'].to_i + args['y'].to_i + args['z'].to_i
end

#queuing code
Stalker.enqueue 'crazy.calculation', {:x => 1, :y => 2, :z => 3}, {:ttr => 3600}

The same code if your calcuation doesn't take arguments

#job code
job 'crazy.calculation' do |args|
  1 + 2 + 3
end

#queuing code
Stalker.enqueue 'crazy.calculation', {}, {:ttr => 3600}

Don't confused by the interchangeability of symbols and strings in the enqueue args hash and the job args hash, in the options hash :ttr MUST BE A SYMBOL.

Chad M
  • 943
  • 1
  • 9
  • 22
  • 1
    Changing ttr is not a good option from beanstalkd perspective. You supposed to use **'[touch](http://rubydoc.info/gems/beanstalk-client/1.1.0/Beanstalk/Job#touch-instance_method)'** while performing time consuming operations. However this functionality is not implemented in stalker. – guiding5 Sep 01 '11 at 14:40
  • Any suggestions on how to touch beanstalkd then? Is it possible to include it in the Stalker job? As in keep time, and when it hits 115s, touch beanstalk. – undefinedvariable Dec 13 '12 at 18:34