mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -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
|
store.redis_raw_connection = redis.without_namespace
|
||||||
severities = [Logger::WARN, Logger::ERROR, Logger::FATAL, Logger::UNKNOWN]
|
severities = [Logger::WARN, Logger::ERROR, Logger::FATAL, Logger::UNKNOWN]
|
||||||
|
|
||||||
RailsMultisite::ConnectionManagement.each_connection do
|
RailsMultisite::ConnectionManagement.safe_each_connection do
|
||||||
error_rate_per_minute =
|
error_rate_per_minute =
|
||||||
begin
|
begin
|
||||||
SiteSetting.alert_admins_if_errors_per_minute
|
SiteSetting.alert_admins_if_errors_per_minute
|
||||||
|
@ -2,8 +2,16 @@
|
|||||||
|
|
||||||
module RailsMultisite
|
module RailsMultisite
|
||||||
class ConnectionManagement
|
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
|
def self.safe_each_connection
|
||||||
self.each_connection do |db|
|
each_active_connection do |db|
|
||||||
begin
|
begin
|
||||||
yield(db) if block_given?
|
yield(db) if block_given?
|
||||||
rescue PG::ConnectionBad, PG::UnableToSend, PG::ServerError
|
rescue PG::ConnectionBad, PG::UnableToSend, PG::ServerError
|
||||||
|
Loading…
Reference in New Issue
Block a user