Skip to content

Configuration samples

gian edited this page Oct 14, 2016 · 1 revision

sidekiq.yml sample file

:concurrency: 1
:pidfile: tmp/pids/sidekiq.pid
:logfile: log/sidekiq.log
staging:
  :concurrency: 2
production:
  :concurrency: 10
:queues:
  - default
  - mailers
  - notifier

tasks: &tasks
  NotifierJob:
    every: ["2s"]
    queue: notifier
    description: 'Send pending notifications'

:schedule:
  <<: *tasks

Separate .yml file for schedule configuration

If you like to put tasks in another file (ex: scheduler.yml), you have to load it with Yaml.load_file in sidekiq initializer (for rails it is: config/initializers/sidekiq.rb):

# scheduler.yml
NotifierJob:
  every: ["2s"]
  queue: notifier
  description: 'Send pending notifications'
# config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
  config.on(:startup) do
    Sidekiq.schedule = YAML.load_file(File.expand_path('../../scheduler.yml', File.dirname(__FILE__)))
    Sidekiq::Scheduler.reload_schedule!
  end
end