diff --git a/config/environments/production.rb b/config/environments/production.rb index 64ed28732..5008e6071 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,17 +62,21 @@ Rails.application.configure do # Use a different cache store in production. if ENV['REDIS_CACHE_URL'].present? - redis_options = { url: ENV['REDIS_CACHE_URL'] } - redis_options[:ssl] = (ENV['REDIS_CACHE_SSL'] == 'enabled') + redis_options = { + url: ENV['REDIS_CACHE_URL'], + connect_timeout: 0.2, + error_handler: -> (method:, returning:, exception:) { + Sentry.capture_exception exception, level: 'warning', + tags: { method: method, returning: returning } + } + } + + redis_options[:ssl] = ENV['REDIS_CACHE_SSL'] == 'enabled' + if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled' redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } end - redis_options[:error_handler] = -> (method:, returning:, exception:) { - Sentry.capture_exception exception, level: 'warning', - tags: { method: method, returning: returning } - } - config.cache_store = :redis_cache_store, redis_options end diff --git a/config/initializers/kredis.rb b/config/initializers/kredis.rb index 48a7a7a21..daf0d0c5f 100644 --- a/config/initializers/kredis.rb +++ b/config/initializers/kredis.rb @@ -1,6 +1,7 @@ redis_shared_options = { url: ENV['REDIS_CACHE_URL'], # will fallback to default redis url if empty, and won't fail if there is no redis server - ssl: ENV['REDIS_CACHE_SSL'] == 'enabled' + ssl: ENV['REDIS_CACHE_SSL'] == 'enabled', + connect_timeout: 0.2 } redis_shared_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'