开发者

Getting extra rufus-scheduler thread with each delayed_job rake jobs:work

Am trying to use rufus-scheduler to check every minute or so to see if there are jobs ready to be placed in the delayed_job queue.

Have an initializer script in #{RAILS_ROOT}/config/initializers that starts the scheduler. Unfortunately the rake jobs:work also runs the rails initialization process so another gets started for each jobs:work started.

How can I preve开发者_StackOverflow中文版nt this?

Running ruby 1.8.6.26, rails 2.3.5, dj 1.8.5, rufus-scheduler 2.0.6 on XP pro sp3


In your initializer, find a way not to run the schedule if the rails initialization process is invoked via Rake.

For sure there is a more railsy way, but you could do

  unless defined?(Rake)
    # do the scheduling...
  end

The block 'do the scheduling' won't get called if the constant Rake is defined (for a Rake task it is defined).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜