0

I am trying to figure out how can you write specific Sidekiq configuration depending on the environment. I know that you can write in config/sidekiq.yml something like:

:concurrency: 5
:verbose: false
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - [carrierwave, 7]
  - [client_emails, 5]
  - [default, 3]
staging:
  :concurrency: 10
production:
  :concurrency: 25

However, right now and based on: por.rb, I would have the Redis configuration in that file. But the Redis address changes whether the Sidekiq is running in localhost or in Amazon. So my question is, in pure Ruby, how do you write specific configuration-environment files? I know in Rails you would write specific ones under config/initializers/environment/sidekiq.rb, but what about in pure Ruby?

Hommer Smith
  • 26,772
  • 56
  • 167
  • 296

1 Answers1

1

To support multiple environments in sidekiq - look at this: Sidekiq configuration for multiple environments

For your specific question - how to implement initializers in pure ruby, you can put them anywhere you want, but you need to require them in your main file.

If you want to be a little more sophisticated (or you have a lot of initializers), you can require all of them under a folder (initializers/ for example), and then require anything under that folder:

Dir["/initializers/*.rb"].each {|file| require file }
Community
  • 1
  • 1
Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
  • my main concern is how do I tell Sidekiq to load one particular configuration depending on the environment. The answers to the question you pointed refer to Rails environments, but I want to be able to tell Sidekiq that when I launch it with -e 'production' to use a specific config file. So, in a simpler way: How do I tell Sidekiq that in production it needs to use a Redis server, and in development it needs to use a different one. – Hommer Smith Jun 28 '14 at 17:43