Show a more useful message when redis config can't be found during init.

This commit is contained in:
Neil Lalonde 2013-05-15 10:07:16 -04:00
parent d4b8e727fc
commit 2df46a9d0a
1 changed files with 6 additions and 0 deletions

View File

@ -57,6 +57,12 @@ class DiscourseRedis
def self.new_redis_store
redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
unless redis_config
puts '', "Redis config for environment '#{Rails.env}' was not found in #{Rails.root}/config/redis.yml."
puts "Did you forget to do RAILS_ENV=production?"
puts "Check your redis.yml and make sure it has configuration for the environment you're trying to use.", ''
raise 'Redis config not found'
end
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