简体   繁体   中英

Ruby on Rails multiple workers with Sidekiq

I'm working with Ruby on Rails application, I need some background process that's why I'm using sidekiq when I'm using one worker then working nice.

Example this below code: For 1 job

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

Above code working fine. Problem is below code when trying to multiple workers.

#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

This is not running, I don't know what I'm doing wrong.

Every class look like this below:

class SendNews
  include Sidekiq::Worker

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

On the class & method working fine when it's single.

Thanks

Just a guess, have you tried with this?

#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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