Basic Heroku integration

This commit is contained in:
nverba
2013-03-10 12:51:49 +00:00
parent 8e6a8eae66
commit 68e3f5228f
9 changed files with 221 additions and 10 deletions

View File

@ -4,8 +4,9 @@
class DiscourseRedis
def initialize
@config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
@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)
end
@ -36,14 +37,14 @@ class DiscourseRedis
end
def self.new_redis_store
redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{(':' + redis_config['password'] + '@') if redis_config['password']}#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
redis_store.options[:namespace] = -> { DiscourseRedis.namespace }
redis_store
end
def url
"redis://#{@config['host']}:#{@config['port']}/#{@config['db']}"
"redis://#{(':' + @config['password'] + '@') if @config['password']}#{@config['host']}:#{@config['port']}/#{@config['db']}"
end
end