【发布时间】:2011-08-24 20:59:59
【问题描述】:
我正在尝试使用 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,计划会正确加载,但我需要设置此选项,因为计划会随时间变化
【问题讨论】:
-
无法让它运行但使用了另一种方式,我只是编写脚本来杀死调度程序进程,然后每次更改文件时重新启动它,这可能不是最好的解决方案,但是有用。如果有人可以解决这个问题,请保持开放状态。