mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix #26708 by using the previously set REDIS_URL as defaults that can be overriden by other REDIS env variables
This commit is contained in:
parent
1471be8225
commit
6e50216288
1 changed files with 16 additions and 5 deletions
|
@ -4,12 +4,23 @@ def setup_redis_env_url(prefix = nil, defaults = true)
|
||||||
prefix = "#{prefix.to_s.upcase}_" unless prefix.nil?
|
prefix = "#{prefix.to_s.upcase}_" unless prefix.nil?
|
||||||
prefix = '' if prefix.nil?
|
prefix = '' if prefix.nil?
|
||||||
|
|
||||||
return if ENV["#{prefix}REDIS_URL"].present?
|
if ENV["#{prefix}REDIS_URL"].present?
|
||||||
|
address = Addressable::URI.parse(ENV["#{prefix}REDIS_URL"])
|
||||||
|
password = address.password
|
||||||
|
host = address.host
|
||||||
|
port = address.port
|
||||||
|
db = address.path.delete_prefix('/')
|
||||||
|
else
|
||||||
|
password = ''
|
||||||
|
host = 'localhost'
|
||||||
|
port = 6379
|
||||||
|
db = 0
|
||||||
|
end
|
||||||
|
|
||||||
password = ENV.fetch("#{prefix}REDIS_PASSWORD") { '' if defaults }
|
password = ENV.fetch("#{prefix}REDIS_PASSWORD") { password if defaults }
|
||||||
host = ENV.fetch("#{prefix}REDIS_HOST") { 'localhost' if defaults }
|
host = ENV.fetch("#{prefix}REDIS_HOST") { host if defaults }
|
||||||
port = ENV.fetch("#{prefix}REDIS_PORT") { 6379 if defaults }
|
port = ENV.fetch("#{prefix}REDIS_PORT") { port if defaults }
|
||||||
db = ENV.fetch("#{prefix}REDIS_DB") { 0 if defaults }
|
db = ENV.fetch("#{prefix}REDIS_DB") { db if defaults }
|
||||||
|
|
||||||
ENV["#{prefix}REDIS_URL"] = begin
|
ENV["#{prefix}REDIS_URL"] = begin
|
||||||
if [password, host, port, db].all?(&:nil?)
|
if [password, host, port, db].all?(&:nil?)
|
||||||
|
|
Loading…
Reference in a new issue