我已經看過多個來源,並嘗試過各種方案,但無法解決這個問題。請指向正確的方向。多個環境的Sidekiq配置
和大家一樣,我有3個env(開發,分期和生產)。
我在sidekiq.yml文件
# Options here can still be overridden by cmd line args.
# sidekiq -C config.yml
---
:verbose: false
:namespace: xyz
:logfile: log/sidekiq.log
:concurrency: 25
:strict: false
:pidfile: tmp/pids/sidekiq.pid
:queues:
- [stg_xyz_tests_queue, 10]
- [stg_default_xyz_queue, 2]
- [stg_xyz_default_queue, 3]
development:
:verbose: true
:concurrency: 15
:queues:
- [dev_xyz_queue, 10]
- [dev_default_xyz_queue, 2]
- [dev_xyz_default_queue, 3]
staging:
:queues:
- [stg_xyz_queue, 10]
- [stg_default_xyz_queue, 2]
- [stg_xyz_default_queue, 3]
production:
:queues:
- [prod_xyz_queue, 10]
- [prod_default_xyz_queue, 2]
- [prod_xyz_default_queue, 3]
有了這個,我希望下面的,當我開始sidekiq用命令
RAILS_ENV=#{rails_env} bundle exec sidekiq -C config/sidekiq.yml
,它會皮卡全部來自值配置文件,並在log/sidekiq.log中使用相應的隊列和日誌文件啓動sidekiq,但不起作用。 Sidekiq啓動,但無論我們使用什麼環境,它只會創建stg_xyz_tests_queue,stg_default_xyz_queue和stg_xyz_default_queue。
另一種方法我試過用下面的代碼在config /環境/ development.rb
#configure Sidekiq for dev environment
Sidekiq.configure_server do |config|
config.options[:namespace] = "xyz"
config.options[:concurrency] = 25
config.options[:verbose] = true
config.options[:strict] = false
config.options[:logfile] = "log/sidekiq.log"
config.options[:pidfile] = "tmp/pids/sidekiq.pid"
queues = Array.new
10.times do
queues.push "dev_xyz_queue"
end
2.times do
queues.push "dev_default_xyz_queue"
end
3.times do
queues.push "dev_xyz_default_queue"
end
config.options[:queues] = queues
puts "Sidekiq server config options for development => #{config.options.to_yaml}"
end
有了這個隊列創建好,但日誌文件不創建或寫,我需要複製這個代碼適用於所有3種環境。
什麼是最好的方式讓sidekiq無縫工作我的設置 感謝您的幫助提前!
[鏈接](https://github.com/mperham/sidekiq/issues/758 )Sidekiq網站的問題列爲問題 – user1687078 2013-03-07 00:22:54