REFACTOR: Move the multisite middleware to the front

Both request tracking and message bus rely on multisite before the
middleware has run which is not ideal.
This commit is contained in:
Daniel Waterworth
2020-03-30 12:01:06 +01:00
parent 8a50ab45aa
commit a91843f0dc
3 changed files with 21 additions and 24 deletions

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
module RailsMultisite
class ConnectionManagement
def self.safe_each_connection
self.each_connection do |db|
begin
yield(db) if block_given?
rescue => e
STDERR.puts "URGENT: Failed to initialize site #{db}: "\
"#{e.class} #{e.message}\n#{e.backtrace.join("\n")}"
# the show must go on, don't stop startup if multisite fails
end
end
end
end
class DiscoursePatches
def self.config
{
db_lookup: lambda do |env|
env["PATH_INFO"] == "/srv/status" ? "default" : nil
end
}
end
end
end