diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-27 16:36:38 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-08-27 16:36:38 +0200 |
commit | 0a52b70b923af6d4351d4b7a28527c6740e812cf (patch) | |
tree | 6789e4eda832502c47bf18477c2e4f14d03db0d0 /config | |
parent | 6d785abaa9367173d62300b8000a68554e4e293c (diff) | |
download | gitlab-ce-0a52b70b923af6d4351d4b7a28527c6740e812cf.tar.gz |
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.
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/7_cache_settings.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/config/initializers/7_cache_settings.rb b/config/initializers/7_cache_settings.rb index ce7e8c5a650..5367a4d431c 100644 --- a/config/initializers/7_cache_settings.rb +++ b/config/initializers/7_cache_settings.rb @@ -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 -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 + end -redis_config_hash[:namespace] = 'cache:gitlab' + redis_config_hash[:namespace] = 'cache:gitlab' -Gitlab::Application.config.cache_store = :redis_store, redis_config_hash + config.cache_store = :redis_store, redis_config_hash +end |