Search code examples
ruby-on-railsrubynamespacesredissidekiq

Why is redis namespacing with Sidekiq not working?


I'm running my production and staging environment on the same server. I'm trying to setup namespaces based on which environment that is running. For instance, I do not want my production environment to handle e-mails queued by the staging environment and vice versa. I'm using the same code for my local environment.

Here is the code:

# config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
  config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_app_name_#{Rails.env}" }
end

Sidekiq.configure_client do |config|
  config.redis = { url: 'redis://localhost:6379/0', namespace: "sidekiq_app_name_#{Rails.env}" }
end 

Whenever I use this code the e-mails are being sent to the Default queue but they are not being processed. If I remove the "namespace" part, everything goes back to normal. This has just been tested locally so far.

Any ideas what I might be missing here?

I'm running sidekiq v3.3.0 as well as capistrano-sidekiq 0.4.0 for deploying.


Solution

  • I managed to solve this on my own. The problem was that I somehow manage to add the following code inside config.ru:

    require 'sidekiq'
    
    Sidekiq.configure_client do |config|
      config.redis = { :size => 1 }
    end
    

    Once removed, everything worked!