我正在使用resque和rufus调度程序。
我已经为两个不同的 resque 作业创建了两个不同的队列,并且能够执行这两个队列。
但是我面临一个问题,因为两个队列每次都执行两次。
这是 Scheduler.rb 文件:
目录 : config/initializers/scheduler.rb
require 'rubygems'
require 'rufus/scheduler'
scheduler = Rufus::Scheduler.new
scheduler.cron '46 19 * * *' do
Resque::Job.create(:monitoring_queue, Monitoring)
end
scheduler.every '60m' do
Resque::Job.create(:execute_monitoring_queue, ExecuteMonitor)
end
这是 resque 作业文件-1 监控.rb
class Monitoring
@queue = :monitoring_queue
def self.perform()
begin
Monitor.check_and_confirm
NotificationMailer.notification_email.deliver
rescue Exception => e
puts e.message
e.backtrace.join("n")
end
end
end
这是 resque 作业文件-2 execute_monitor.rb
class ExecuteMonitor
@queue = :execute_monitoring_queue
def self.perform()
begin
Monitor.confirm_and_check
NotificationMailer.notification_email.deliver
rescue Exception => e
puts e.message
e.backtrace.join("n")
end
end
end
任何人都可以告诉我为什么这些队列每次都执行两次,或者我错过了什么。
只要让我知道任何需要的东西。
不是直接的答案,但可以提供帮助:
- 当我们有多个 EC2 实例时,rufus-scheduler 出现问题
- Rufus 调度程序使用独角兽多次运行,使用 :lockfile 修复,但如何消除错误 msg?
- Rufus-调度程序由于独角兽工人而多次运行调度程序
https://stackoverflow.com/questions/tagged/rufus-scheduler......
在 rufus-scheduler 文档中:
- https://github.com/jmettraux/rufus-scheduler#lockfile--mylockfiletxt
- https://github.com/jmettraux/rufus-scheduler#scheduler_lock
- https://github.com/jmettraux/rufus-scheduler#advanced-lock-schemes