DEV: s/\$redis/Discourse\.redis (#8431)

This commit also adds a rubocop rule to prevent global variables.
This commit is contained in:
Joffrey JAFFEUX
2019-12-03 10:05:53 +01:00
committed by GitHub
parent 9eccfb7b52
commit 0d3d2c43a0
118 changed files with 378 additions and 362 deletions

View File

@@ -243,7 +243,7 @@ module Discourse
require 'logster/redis_store'
# Use redis for our cache
config.cache_store = DiscourseRedis.new_redis_store
$redis = DiscourseRedis.new
$redis = DiscourseRedis.new # rubocop:disable Style/GlobalVars
Logster.store = Logster::RedisStore.new(DiscourseRedis.new)
# we configure rack cache on demand in an initializer

View File

@@ -2,5 +2,5 @@
if Rails.env.development? && ENV['DISCOURSE_FLUSH_REDIS']
puts "Flushing redis (development mode)"
$redis.flushall
Discourse.redis.flushall
end

View File

@@ -24,7 +24,7 @@ end
MiniScheduler.configure do |config|
config.redis = $redis
config.redis = Discourse.redis
config.job_exception_handler do |ex, context|
Discourse.handle_job_exception(ex, context)

View File

@@ -29,7 +29,7 @@ Thread.new do
if old_time != time
Rails.logger.info "attempting to reload #{$$} #{$PROGRAM_NAME} in #{wait_seconds} seconds"
$shutdown = true
$shutdown = true # rubocop:disable Style/GlobalVars
sleep wait_seconds
Rails.logger.info "restarting #{$$}"
Process.kill("USR2", $$)

View File

@@ -155,7 +155,7 @@ before_fork do |server, worker|
sleep 10
force_kill_rogue_sidekiq
end
$redis._client.disconnect
Discourse.redis._client.disconnect
end
end
@@ -170,7 +170,7 @@ before_fork do |server, worker|
end
$redis._client.disconnect
Discourse.redis._client.disconnect
# Throttle the master from forking too quickly by sleeping. Due
# to the implementation of standard Unix signal handlers, this