diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/cable.yml | 2 | ||||
-rw-r--r-- | config/environments/production.rb | 12 | ||||
-rw-r--r-- | config/initializers/redis.rb | 1 | ||||
-rw-r--r-- | config/initializers/sidekiq.rb | 5 | ||||
-rw-r--r-- | config/puma.rb | 5 |
5 files changed, 21 insertions, 4 deletions
diff --git a/config/cable.yml b/config/cable.yml index 978f721af..34759a772 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,4 +7,4 @@ test: production: adapter: redis - url: redis://<%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1 + url: redis://<%= ENV['REDIS_PASSWORD'] ? ':' + ENV['REDIS_PASSWORD'] + '@' : '' %><%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1 diff --git a/config/environments/production.rb b/config/environments/production.rb index 9254d494c..8b8d974b3 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -45,10 +45,20 @@ Rails.application.configure do # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + # Parse and split the REDIS_URL if passed (used with hosting platforms such as Heroku). + # Set ENV variables because they are used elsewhere. + if ENV['REDIS_URL'] + redis_url = URI.parse(ENV['REDIS_URL']) + ENV['REDIS_HOST'] = redis_url.host + ENV['REDIS_PORT'] = redis_url.port.to_s + ENV['REDIS_PASSWORD'] = redis_url.password + end + # Use a different cache store in production. config.cache_store = :redis_store, { host: ENV.fetch('REDIS_HOST') { 'localhost' }, port: ENV.fetch('REDIS_PORT') { 6379 }, + password: ENV.fetch('REDIS_PASSWORD') { false }, db: 0, namespace: 'cache', expires_in: 20.minutes @@ -85,7 +95,7 @@ Rails.application.configure do :address => ENV['SMTP_SERVER'], :user_name => ENV['SMTP_LOGIN'], :password => ENV['SMTP_PASSWORD'], - :domain => config.x.local_domain, + :domain => ENV['SMTP_DOMAIN'] || config.x.local_domain, :authentication => :plain, } diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index 3825710b8..3660c4a9b 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -3,5 +3,6 @@ Redis.current = Redis.new( host: ENV.fetch('REDIS_HOST') { 'localhost' }, port: ENV.fetch('REDIS_PORT') { 6379 }, + password: ENV.fetch('REDIS_PASSWORD') { false }, driver: :hiredis ) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 63fdb3f16..ecdd07b08 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,10 +1,11 @@ host = ENV.fetch('REDIS_HOST') { 'localhost' } port = ENV.fetch('REDIS_PORT') { 6379 } +password = ENV.fetch('REDIS_PASSWORD') { false } Sidekiq.configure_server do |config| - config.redis = { host: host, port: port } + config.redis = { host: host, port: port, password: password} end Sidekiq.configure_client do |config| - config.redis = { host: host, port: port } + config.redis = { host: host, port: port, password: password } end diff --git a/config/puma.rb b/config/puma.rb index ad2dbfffd..e6b0da91b 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -40,6 +40,11 @@ preload_app! # cannot share connections between processes. # on_worker_boot do + + if ENV["HEROKU"] #Spwan the workers from Puma, to only use one dyno + @sidekiq_pid ||= spawn('bundle exec sidekiq -q default -q mailers -q push') + end + ActiveRecord::Base.establish_connection if defined?(ActiveRecord) end |