Skip to content

Commit

Permalink
Follow up to f6f2c38.
Browse files Browse the repository at this point in the history
Master connection might fail.
  • Loading branch information
tgxworld committed Jan 22, 2019
1 parent f6f2c38 commit 4dbebb4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/discourse_redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def initiate_fallback_to_master
success = false

begin
master_client = ::Redis::Client.new(DiscourseRedis.config)
redis_config = DiscourseRedis.config.dup
redis_config.delete(:connector)
master_client = ::Redis::Client.new(redis_config)
logger.warn "#{log_prefix}: Checking connection to master server..."
info = master_client.call([:info])

Expand All @@ -64,6 +66,8 @@ def initiate_fallback_to_master
slave_client&.disconnect
end
end
rescue => e
logger.warn "#{log_prefix}: Connection to Master server failed with '#{e.message}'"
ensure
master_client&.disconnect
end
Expand Down

0 comments on commit 4dbebb4

Please sign in to comment.