Add REDIS_DB env variable to configure Redis database (#1366)

th-downstream
Les Orchard 8 years ago committed by Eugen
parent c45c67c2ac
commit 492e8ec00e

@ -1,6 +1,7 @@
# Service dependencies # Service dependencies
REDIS_HOST=redis REDIS_HOST=redis
REDIS_PORT=6379 REDIS_PORT=6379
# REDIS_DB=0
DB_HOST=db DB_HOST=db
DB_USER=postgres DB_USER=postgres
DB_NAME=postgres DB_NAME=postgres

@ -55,6 +55,8 @@ Rails.application.configure do
ENV['REDIS_HOST'] = redis_url.host ENV['REDIS_HOST'] = redis_url.host
ENV['REDIS_PORT'] = redis_url.port.to_s ENV['REDIS_PORT'] = redis_url.port.to_s
ENV['REDIS_PASSWORD'] = redis_url.password ENV['REDIS_PASSWORD'] = redis_url.password
db_num = redis_url.path[1..-1]
ENV['REDIS_DB'] = db_num if db_num.present?
end end
# Use a different cache store in production. # Use a different cache store in production.
@ -62,7 +64,7 @@ Rails.application.configure do
host: ENV.fetch('REDIS_HOST') { 'localhost' }, host: ENV.fetch('REDIS_HOST') { 'localhost' },
port: ENV.fetch('REDIS_PORT') { 6379 }, port: ENV.fetch('REDIS_PORT') { 6379 },
password: ENV.fetch('REDIS_PASSWORD') { false }, password: ENV.fetch('REDIS_PASSWORD') { false },
db: 0, db: ENV.fetch('REDIS_DB') { 0 },
namespace: 'cache', namespace: 'cache',
expires_in: 10.minutes, expires_in: 10.minutes,
} }

@ -1,11 +1,12 @@
host = ENV.fetch('REDIS_HOST') { 'localhost' } host = ENV.fetch('REDIS_HOST') { 'localhost' }
port = ENV.fetch('REDIS_PORT') { 6379 } port = ENV.fetch('REDIS_PORT') { 6379 }
password = ENV.fetch('REDIS_PASSWORD') { false } password = ENV.fetch('REDIS_PASSWORD') { false }
db = ENV.fetch('REDIS_DB') { 0 }
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.redis = { host: host, port: port, password: password} config.redis = { host: host, port: port, db: db, password: password }
end end
Sidekiq.configure_client do |config| Sidekiq.configure_client do |config|
config.redis = { host: host, port: port, password: password } config.redis = { host: host, port: port, db: db, password: password }
end end

Loading…
Cancel
Save