Skip to content

Instantly share code, notes, and snippets.

@nverba
Last active December 14, 2015 16:38
Show Gist options
  • Save nverba/5116240 to your computer and use it in GitHub Desktop.
Save nverba/5116240 to your computer and use it in GitHub Desktop.
Experimental deployment of Discourse for Heroku. Work in progress.

Basic Heroku deployment - experimental

Update 4 files to be able to parse config/redis.yml with ERB.

config/initializers/message_bus.rb

- MessageBus.redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env].symbolize_keys

+ MessageBus.redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env].symbolize_keys

config/initializers/mini_profiler.rb

- Rack::MiniProfiler.config.storage_options = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env].symbolize_keys

+ Rack::MiniProfiler.config.storage_options = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env].symbolize_keys

In these last two files, also include the password config.

config/application.rb

- 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']}@#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"

lib/discourse_redis.rb

- @config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
- redis_opts = {:host => @config['host'], :port => @config['port'], :db => @config['db']}

+ @config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
+ redis_opts = {:host => @config['sidekiq_host'], :port => @config['sidekiq_port'], :db => @config['db'], :password => @config['sidekiq_password']}

console commands

bundle exec foreman run rake assets:precompile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment