resque-status和resque-scheduler用于重复性作业

时间:2012-11-19 20:03:55

标签: ruby resque

我的resque系统有以下配置(没有rails只有Sinatra base)我从yml文件中安排了一堆定期作业

resque (1.23.0)
resque-scheduler (2.0.0)
resque-status (0.4.0)

定期计划显示在“计划”选项卡上,当我单击“队列现在”按钮时,状态也会显示在“状态”选项卡上,问题是当定期作业自动运行时,它们不会出现在“状态”选项卡上..我的resque_schedule.yml看起来像这样

email_notifier:
  every: 5m
  custom_job_class: Process_Notification_Emails
  queue: email_notifier
  args: 
  description: "Process mail notifications"

注意:这些预定作业实际上每5分钟运行一次,并且按预期运行,我唯一的问题是它们不会出现在“状态”选项卡上,除非我手动将它们排队

任何想法我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

  

支持resque-status(和其他自定义作业)

     

某些像resque-status这样的Resque扩展使用自定义作业类   一个稍微不同的API签名。 Resque-scheduler没有尝试   支持所有现有和未来的自定义作业类,而不是它   支持计划标志,以便您可以扩展自定义类并进行制作   它支持预定的工作。

     

让我们假装我们有一个名为FakeLeaderboard的JobWithStatus类

class FakeLeaderboard < Resque::JobWithStatus
  def perform
    # do something and keep track of the status
  end
end
  

然后是时间表:

create_fake_leaderboards:
  cron: "30 6 * * 1"
  queue: scoring
  custom_job_class: FakeLeaderboard
  args:
  rails_env: demo
  description: "This job will auto-create leaderboards for our online demo and the status will update as the worker makes progress"
  

如果您的扩展程序不支持预定作业,则需要   扩展自定义作业类以支持#scheduled方法:

module Resque
  class JobWithStatus
    # Wrapper API to forward a Resque::Job creation API call into
    # a JobWithStatus call.
    def self.scheduled(queue, klass, *args)
      create(*args)
    end
  end
end

https://github.com/bvandenbos/resque-scheduler#support-for-resque-status-and-other-custom-jobs

相关问题