Resque-scheduler动态报告“计划空”

时间:2011-08-24 21:00:00

标签: ruby-on-rails-3 resque

我正在尝试使用resque-scheduler gem来安排我安装gem(V 2.0.0d)的作业并遵循github上写的信息 这是我的resque.rake文件

# Resque tasks
require 'resque/tasks'
require 'resque_scheduler/tasks' 



namespace :resque do
  task :setup do
    require 'resque'
    require 'resque_scheduler'
    require 'resque/scheduler'     



# you probably already have this somewhere
Resque.redis = 'localhost:6379'

# The schedule doesn't need to be stored in a YAML, it just needs to
# be a hash.  YAML is usually the easiest.
Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")


# If you want to be able to dynamically change the schedule,
# uncomment this line.  A dynamic schedule can be updated via the
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
# When dynamic is set to true, the scheduler process looks for 
# schedule changes and applies them on the fly.
# Note: This feature is only available in >=2.0.0.
Resque::Scheduler.dynamic = true



 end
end

但每次我运行rake resque:scheduler时都会说

加载时间表   安排空!设置Resque.schedule   加载时间表

如果删除Resque::Scheduler.dynamic = true,则会正确加载计划,但我需要设置此选项,因为计划会随着时间的推移而变化

1 个答案:

答案 0 :(得分:3)

您可以通过放置以下代码来解决此问题:

Resque::Scheduler.dynamic = true

就在上面:

Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")

有关详细信息,请查看https://github.com/bvandenbos/resque-scheduler/issues/115