2017-08-27 66 views
0

我正在使用Ruby on Rails應用程序,我需要一些後臺進程,這就是爲什麼我使用sidekiq當我使用一個工人,然後工作很好。Ruby on Rails多個工人與Sidekiq

例如,這下面的代碼:對於1個作業

#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 

在類&方法工作正常時,它的單。

謝謝

回答

1

只是猜測,你試過這個嗎?

#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