【问题标题】:Resque-scheduler dynamic reports "schedule empty"Resque-scheduler 动态报告“schedule empty”
【发布时间】: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,计划会正确加载,但我需要设置此选项,因为计划会随时间变化

【问题讨论】:

  • 无法让它运行但使用了另一种方式,我只是编写脚本来杀死调度程序进程,然后每次更改文件时重新启动它,这可能不是最好的解决方案,但是有用。如果有人可以解决这个问题,请保持开放状态。

标签: ruby-on-rails-3 resque


【解决方案1】:

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

Resque::Scheduler.dynamic = true

就在下面:

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

欲了解更多信息,请查看https://github.com/bvandenbos/resque-scheduler/issues/115

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 2011-01-25
    • 2014-09-30
    • 2014-04-23
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    相关资源
    最近更新 更多