我的 resque 系统有以下配置(没有轨道,只有 Sinatra 基础),我从 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 分钟运行一次并且按预期运行,我遇到的唯一问题是它们不会出现在"状态"选项卡上,除非我手动将它们排队
任何想法我在这里做错了什么?
支持重新设置状态(和其他自定义作业)
一些 Resque 扩展(如 resque-status)使用自定义作业类 略有不同的 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