开发者

Stalker Timeout - How do I change the timeout settings?

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
开发者_运维知识库


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜