mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
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:
28
lib/freedom_patches/rails_multisite.rb
Normal file
28
lib/freedom_patches/rails_multisite.rb
Normal 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
|
Reference in New Issue
Block a user