简体   繁体   English

在开发中使用resque和rufus Scheduler两次执行该作业

[英]job gets executed twice working with resque and rufus scheduler on development

I am working with resque and rufus scheduler. 我正在使用resque和rufus调度程序。

I have created two different queues for the two different resque jobs and able to execute both the queues. 我为两个不同的resque作业创建了两个不同的队列,并且能够执行两个队列。

But I am facing one issue as both the queues are executing twice every time. 但是我面临一个问题,因为两个队列每次都执行两次。

Here is the Scheduler.rb file : 这是Scheduler.rb文件:

Directory : config/initializers/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

Here is the resque job file-1 monitoring.rb 这是resque作业文件1 Monitoring.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

Here is the resque job file-2 execute_monitor.rb 这是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

can any please tell me why those queues are executing twice every time or is there something that I am missing. 可以告诉我为什么这些队列每次都执行两次,或者我缺少什么吗?

Just let me know anything needed. 只要让我知道需要什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM