繁体   English   中英

Ruby on Rails与Sidekiq的多名工人

[英]Ruby on Rails multiple workers with Sidekiq

我正在使用Ruby on Rails应用程序,我需要一些后台进程,这就是为什么当我使用一个工作人员并且工作得很好时,我使用sidekiq的原因。

下面的代码示例: 一份工作

#app/config/sidekiq.yml
:schedule:
    send_news:
        cron: "0 20 * * * America/Los_Angeles"
        class: SendNews

上面的代码工作正常。 尝试多个工作人员时,问题出在代码下面。

#app/config/sidekiq.yml
:schedule:
    send_news:
        cron: "0 20 * * * America/Los_Angeles"
        class: SendNews

:schedule:
    send_notification:
        cron: "0 21 * * * America/Los_Angeles"
        class: SendNotification

:schedule:
    send_summery:
        cron: "0 22 * * * America/Los_Angeles"
        class: SendSummery

这没有运行,我不知道我在做什么错。

每个类如下所示:

class SendNews
  include Sidekiq::Worker

  def perform
    load File.join(Rails.root, 'lib', 'task_helpers', 'news_helper.rb')
    NewsHelper.today_news
  end
end

在单一的类和方法上工作正常。

谢谢

只是一个猜测,您尝试过吗?

#app/config/sidekiq.yml
:schedule:
  send_news:
    cron: "0 20 * * * America/Los_Angeles"
    class: SendNews
  send_notification:
    cron: "0 21 * * * America/Los_Angeles"
    class: SendNotification
  send_summery:
    cron: "0 22 * * * America/Los_Angeles"
    class: SendSummery

暂无
暂无

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

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