Hide configuration shenanigans in a block
I'm feeling paranoid about the scope variables like redis_config_file get defined in. Hiding it in a block to limit the scope.
This commit is contained in:
parent
6d785abaa9
commit
0a52b70b92
|
@ -1,18 +1,20 @@
|
|||
redis_config_file = Rails.root.join('config', 'resque.yml')
|
||||
Gitlab::Application.configure do
|
||||
redis_config_file = Rails.root.join('config', 'resque.yml')
|
||||
|
||||
redis_url_string = if File.exists?(redis_config_file)
|
||||
YAML.load_file(redis_config_file)[Rails.env]
|
||||
else
|
||||
"redis://localhost:6379"
|
||||
end
|
||||
redis_url_string = if File.exists?(redis_config_file)
|
||||
YAML.load_file(redis_config_file)[Rails.env]
|
||||
else
|
||||
"redis://localhost:6379"
|
||||
end
|
||||
|
||||
# Redis::Store does not handle Unix sockets well, so let's do it for them
|
||||
redis_config_hash = Redis::Store::Factory.extract_host_options_from_uri(redis_url_string)
|
||||
redis_uri = URI.parse(redis_url_string)
|
||||
if redis_uri.scheme == 'unix'
|
||||
redis_config_hash[:path] = redis_uri.path
|
||||
# Redis::Store does not handle Unix sockets well, so let's do it for them
|
||||
redis_config_hash = Redis::Store::Factory.extract_host_options_from_uri(redis_url_string)
|
||||
redis_uri = URI.parse(redis_url_string)
|
||||
if redis_uri.scheme == 'unix'
|
||||
redis_config_hash[:path] = redis_uri.path
|
||||
end
|
||||
|
||||
redis_config_hash[:namespace] = 'cache:gitlab'
|
||||
|
||||
config.cache_store = :redis_store, redis_config_hash
|
||||
end
|
||||
|
||||
redis_config_hash[:namespace] = 'cache:gitlab'
|
||||
|
||||
Gitlab::Application.config.cache_store = :redis_store, redis_config_hash
|
||||
|
|
Loading…
Reference in New Issue