diff --git a/lib/mastodon/redis_configuration.rb b/lib/mastodon/redis_configuration.rb index 3d739a2ac6..e4fa6e52ba 100644 --- a/lib/mastodon/redis_configuration.rb +++ b/lib/mastodon/redis_configuration.rb @@ -7,6 +7,13 @@ class Mastodon::RedisConfiguration db: 0, }.freeze + def reset! + @base = nil + @sidekiq = nil + @cache = nil + @namespace = nil + end + def base @base ||= setup_config(prefix: nil, defaults: DEFAULTS) .merge(namespace: base_namespace) diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 2822f2eeb1..a159a22264 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -8,14 +8,6 @@ namespace :mastodon do prompt = TTY::Prompt.new env = {} - # When the application code gets loaded, it runs `lib/mastodon/redis_configuration.rb`. - # This happens before application environment configuration and sets REDIS_URL etc. - # These variables are then used even when REDIS_HOST etc. are changed, so clear them - # out so they don't interfere with our new configuration. - ENV.delete('REDIS_URL') - ENV.delete('CACHE_REDIS_URL') - ENV.delete('SIDEKIQ_REDIS_URL') - begin errors = false @@ -533,6 +525,11 @@ namespace :mastodon do ENV[key] = value.to_s end + # Redis configuration happens very early when the application code is loaded. + # This happens before the `mastodon:setup` task runs, so we have to refresh it with + # the new environment variable values. + REDIS_CONFIGURATION.reset! + require_relative '../../config/environment' disable_log_stdout!