簡體   English   中英

Rake 任務不調用 ruby​​ 中的工作任務

[英]Rake task not calling the worker job in ruby

我使用 sidekiq 定義了一個 rake 任務和一個工作任務,如下所示。 rake 任務沒有調用 worker 作業。 請幫我找出我的問題。

Office.rake

namespace :office do
  desc "send reminder emails"
  task send_reminder: :environment do
    Office.all.each do |office|
      (office.issues.includes(:billings).where("issues.api_accounts_receivable > 0").select { |issue| (issue.billings.last.date < Message.last.date) if issue.billings.present? }).each do |issue|
        puts "Issue ID is #{issue["id"]}"
        ReminderWorker.perform_async("#{issue["id"]}")  
      end
    end
  end
end

提醒工人.rb

class ReminderWorker
  include Sidekiq::Worker
  def perform(issue_id)
    puts issue_id
  end
end

puts 不會在工作人員的終端中顯示 issue_id 的輸出,但會顯示當我從終端調用rake office:send_reminder時在 rake 任務中提到的“問題 ID 是 #{issue["id"]}”的輸出

我發現了我的錯誤。 我沒有打開 sidekiq 服務器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM