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 Mini Profiler is included via gem
|
||||||
if defined?(Rack::MiniProfiler)
|
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
|
# 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|
|
Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|
|
||||||
|
|
|
@ -3,11 +3,20 @@
|
||||||
#
|
#
|
||||||
class DiscourseRedis
|
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
|
def initialize
|
||||||
@config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
@config = DiscourseRedis.config
|
||||||
redis_opts = {host: @config['host'], port: @config['port'], db: @config['db']}
|
@redis = DiscourseRedis.raw_connection(@config)
|
||||||
redis_opts[:password] = @config['password'] if @config['password']
|
|
||||||
@redis = Redis.new(redis_opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# prefix the key with the namespace
|
# prefix the key with the namespace
|
||||||
|
|
Loading…
Reference in New Issue