diff --git a/config/initializers/100-logster.rb b/config/initializers/100-logster.rb index 9248e35e326..0f4c1a06e73 100644 --- a/config/initializers/100-logster.rb +++ b/config/initializers/100-logster.rb @@ -81,7 +81,7 @@ store.redis_prefix = Proc.new { redis.namespace } store.redis_raw_connection = redis.without_namespace severities = [Logger::WARN, Logger::ERROR, Logger::FATAL, Logger::UNKNOWN] -RailsMultisite::ConnectionManagement.each_connection do +RailsMultisite::ConnectionManagement.safe_each_connection do error_rate_per_minute = begin SiteSetting.alert_admins_if_errors_per_minute diff --git a/lib/freedom_patches/rails_multisite.rb b/lib/freedom_patches/rails_multisite.rb index 608bf580b03..a4ae7899997 100644 --- a/lib/freedom_patches/rails_multisite.rb +++ b/lib/freedom_patches/rails_multisite.rb @@ -2,8 +2,16 @@ module RailsMultisite class ConnectionManagement + def self.each_active_connection(&blk) + if ENV["RAILS_DB"] + blk.call(current_db) + else + each_connection(&blk) + end + end + def self.safe_each_connection - self.each_connection do |db| + each_active_connection do |db| begin yield(db) if block_given? rescue PG::ConnectionBad, PG::UnableToSend, PG::ServerError