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

丶灬走出姿态 提交于 2020-01-07 04:09:36

问题


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 prevent this?

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


回答1:


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).



来源:https://stackoverflow.com/questions/4661608/getting-extra-rufus-scheduler-thread-with-each-delayed-job-rake-jobswork

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!