discourse/lib/freedom_patches/rails_multisite.rb
Daniel Waterworth bca126f3f5 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.

Follow-up-to: ca1208a636
2020-04-02 16:44:44 +01:00

29 lines
650 B
Ruby

# 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