Hommer Smith
Hommer Smith

Reputation: 27852

Specify environment specific configuration with Sidekiq and plain Ruby

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?

Upvotes: 0

Views: 1160

Answers (1)

Uri Agassi
Uri Agassi

Reputation: 37409

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 }

Upvotes: 1

Related Questions