chore(redis): reduce connect timeout from 1s to 0.2s
Prevent web workers from being stalled when Redis is down.
This commit is contained in:
parent
069cb04e17
commit
f504e7968d
2 changed files with 13 additions and 8 deletions
|
@ -62,17 +62,21 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
if ENV['REDIS_CACHE_URL'].present?
|
if ENV['REDIS_CACHE_URL'].present?
|
||||||
redis_options = { url: ENV['REDIS_CACHE_URL'] }
|
redis_options = {
|
||||||
redis_options[:ssl] = (ENV['REDIS_CACHE_SSL'] == 'enabled')
|
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'
|
if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
|
||||||
redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
redis_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE }
|
||||||
end
|
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
|
config.cache_store = :redis_cache_store, redis_options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
redis_volatile_options = {
|
redis_volatile_options = {
|
||||||
url: ENV['REDIS_CACHE_URL'], # will fallback to default redis url if empty, and won't fail if there is no redis server
|
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_volatile_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
|
redis_volatile_options[:ssl_params] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } if ENV['REDIS_CACHE_SSL_VERIFY_NONE'] == 'enabled'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue