简体   繁体   中英

Redis configuration for sidekiq with different database

My application is running on same server for different environments with sidekiq. I am facing mismatching of sidekiq process in all environments.

So i need to use different database for development/staging/testing environment of same server. How to configure redis to run different database for each environment.

We've used separate sidekiq queues for each environment. It was a bit tricky to get it set up right, but it works.

Then of course you have to run separate workers for each environment, each accessing it's own environment's queue (and it's own environment's database.)

We started doing this because of time we wasted on "integration" tests failing because we had development workers accessing the queue instead of test workers. There may be other ways but this seemed simplest

For multiple Redis Database for each environment in sidekiq

add the below line in config/environment/env.rb as

 require 'sidekiq'

Sidekiq.configure_client do |config|
config.redis = { :namespace => 'xxx', :url => 'redis://127.0.0.1:6379/2' }
end

Sidekiq.configure_server do |config|
config.redis = { :namespace => 'xxx', :url => 'redis://127.0.0.1:6379/2' }
end

So the /2 will define the redis database. create seperate database for each environment by changing the value /3, /4 and so on

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM