mirror of
https://github.com/discourse/discourse.git
synced 2024-11-21 16:38:15 -06:00
PERF: Don't do initialization for every DB if RAILS_DB is set (#28668)
This commit is contained in:
parent
a455567f9e
commit
baf41790dd
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user