mini profiler fix for multisite
This commit is contained in:
parent
8ce9eefdce
commit
36d60befbd
|
@ -1,7 +1,11 @@
|
|||
# If Mini Profiler is included via gem
|
||||
if defined?(Rack::MiniProfiler)
|
||||
|
||||
Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.new)
|
||||
# note, we may want to add some extra security here that disables mini profiler in a multi hosted env unless user global admin
|
||||
# raw_connection means results are not namespaced
|
||||
#
|
||||
# namespacing gets complex, cause mini profiler is in the rack chain way before multisite
|
||||
Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.raw_connection)
|
||||
|
||||
# For our app, let's just show mini profiler always, polling is chatty so nuke that
|
||||
Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|
|
||||
|
|
|
@ -3,11 +3,20 @@
|
|||
#
|
||||
class DiscourseRedis
|
||||
|
||||
def self.raw_connection(config = nil)
|
||||
config ||= self.config
|
||||
redis_opts = {host: config['host'], port: config['port'], db: config['db']}
|
||||
redis_opts[:password] = config['password'] if config['password']
|
||||
Redis.new(redis_opts)
|
||||
end
|
||||
|
||||
def self.config
|
||||
YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
end
|
||||
|
||||
def initialize
|
||||
@config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
redis_opts = {host: @config['host'], port: @config['port'], db: @config['db']}
|
||||
redis_opts[:password] = @config['password'] if @config['password']
|
||||
@redis = Redis.new(redis_opts)
|
||||
@config = DiscourseRedis.config
|
||||
@redis = DiscourseRedis.raw_connection(@config)
|
||||
end
|
||||
|
||||
# prefix the key with the namespace
|
||||
|
|
Loading…
Reference in New Issue