diff options
author | Gabriel Mazetto <gabriel@gitlab.com> | 2016-07-08 03:33:37 +0200 |
---|---|---|
committer | Gabriel Mazetto <gabriel@gitlab.com> | 2016-08-04 18:55:37 +0200 |
commit | 6f318795083ca3d3726bb6bf5f4dc4081cfba8bf (patch) | |
tree | 86e373d0ca88d5ef2d85e5c4f86877a762da64ff /lib | |
parent | eacdb1012032136f32bb0470e6f85714eb7fca6d (diff) | |
download | gitlab-ce-6f318795083ca3d3726bb6bf5f4dc4081cfba8bf.tar.gz |
Fixed specs for Gitlab::Redis and code for Redis Sentinel support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/mail_room.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/redis.rb | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/gitlab/mail_room.rb b/lib/gitlab/mail_room.rb index 745cc79a10e..781c89579b6 100644 --- a/lib/gitlab/mail_room.rb +++ b/lib/gitlab/mail_room.rb @@ -1,12 +1,11 @@ require 'yaml' require 'json' -require_relative 'lib/gitlab/redis' unless defined?(Gitlab::Redis) +require_relative 'redis' unless defined?(Gitlab::Redis) module Gitlab module MailRoom class << self - def enabled? config[:enabled] && config[:address] end @@ -18,7 +17,7 @@ module Gitlab private def fetch_config - return nil unless File.exists?(config_file) + return {} unless File.exist?(config_file) rails_env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' all_config = YAML.load_file(config_file)[rails_env].deep_symbolize_keys @@ -33,11 +32,12 @@ module Gitlab if config[:enabled] && config[:address] config[:redis_url] = Gitlab::Redis.new(rails_env).url end + + config end def config_file - file = ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] || 'config/gitlab.yml' - File.expand_path("../../../#{file}", __FILE__) + ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] || File.expand_path('../../../config/gitlab.yml', __FILE__) end end end diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb index 8c277d97f1a..9c4b01bfe1a 100644 --- a/lib/gitlab/redis.rb +++ b/lib/gitlab/redis.rb @@ -19,7 +19,7 @@ module Gitlab class << self def params - @params || PARAMS_MUTEX.synchronize { @params = new.params } + PARAMS_MUTEX.synchronize { new.params } end # @deprecated Use .params instead to get sentinel support @@ -38,7 +38,7 @@ module Gitlab end def initialize(rails_env=nil) - @rails_env = rails_env || Rails.env + @rails_env = rails_env || ::Rails.env end def params @@ -55,7 +55,7 @@ module Gitlab # Redis::Store does not handle Unix sockets well, so let's do it for them config[:path] = redis_uri.path else - redis_hash = ::Redis::Store::Factory.extract_host_options_from_uri(redis_uri) + redis_hash = ::Redis::Store::Factory.extract_host_options_from_uri(config[:url]) config.merge!(redis_hash) end @@ -74,7 +74,8 @@ module Gitlab end def fetch_config - File.exists?(config_file) ? YAML.load_file(config_file)[@rails_env] : false + file = config_file + File.exist?(file) ? YAML.load_file(file)[@rails_env] : false end def config_file |