about summary refs log tree commit diff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/cable.yml10
-rw-r--r--config/environments/development.rb8
-rw-r--r--config/environments/production.rb21
-rw-r--r--config/initializers/ostatus.rb9
-rw-r--r--config/initializers/redis.rb20
-rw-r--r--config/initializers/sidekiq.rb9
6 files changed, 24 insertions, 53 deletions
diff --git a/config/cable.yml b/config/cable.yml
deleted file mode 100644
index 34759a772..000000000
--- a/config/cable.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-development:
-  adapter: redis
-  url: redis://localhost:6379/1
-
-test:
-  adapter: async
-
-production:
-  adapter: redis
-  url: redis://<%= ENV['REDIS_PASSWORD'] ? ':' + ENV['REDIS_PASSWORD'] + '@' : '' %><%= ENV['REDIS_HOST'] || 'localhost' %>:<%= ENV['REDIS_PORT'] || 6379 %>/1
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 4b25ab1a8..58e8a0728 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -16,14 +16,6 @@ Rails.application.configure do
   if Rails.root.join('tmp/caching-dev.txt').exist?
     config.action_controller.perform_caching = true
 
-    config.cache_store = :redis_store, {
-      host: ENV['REDIS_HOST'] || 'localhost',
-      port: ENV['REDIS_PORT'] || 6379,
-      db: 0,
-      namespace: 'cache',
-      expires_in: 1.minute,
-    }
-
     config.public_file_server.headers = {
       'Cache-Control' => 'public, max-age=172800',
     }
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 1f2b5e05d..3cbf5f899 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -45,27 +45,6 @@ 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
-    db_num = redis_url.path[1..-1]
-    ENV['REDIS_DB'] = db_num if db_num.present?
-  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: ENV.fetch('REDIS_DB') { 0 },
-    namespace: 'cache',
-    expires_in: 10.minutes,
-  }
-
   # Enable serving of images, stylesheets, and JavaScripts from an asset server.
   # config.action_controller.asset_host = 'http://assets.example.com'
 
diff --git a/config/initializers/ostatus.rb b/config/initializers/ostatus.rb
index 155d0a9f1..a905a032c 100644
--- a/config/initializers/ostatus.rb
+++ b/config/initializers/ostatus.rb
@@ -1,9 +1,9 @@
 # frozen_string_literal: true
 
-port  = ENV.fetch('PORT') { 3000 }
-host  = ENV.fetch('LOCAL_DOMAIN') { "localhost:#{port}" }
+port     = ENV.fetch('PORT') { 3000 }
+host     = ENV.fetch('LOCAL_DOMAIN') { "localhost:#{port}" }
 web_host = ENV.fetch('WEB_DOMAIN') { host }
-https = ENV['LOCAL_HTTPS'] == 'true'
+https    = ENV['LOCAL_HTTPS'] == 'true'
 
 Rails.application.configure do
   config.x.local_domain = host
@@ -15,7 +15,6 @@ Rails.application.configure do
   config.x.streaming_api_base_url          = 'http://localhost:4000'
 
   if Rails.env.production?
-    config.action_cable.allowed_request_origins = ["http#{https ? 's' : ''}://#{web_host}"]
-    config.x.streaming_api_base_url             = ENV.fetch('STREAMING_API_BASE_URL') { "http#{https ? 's' : ''}://#{web_host}" }
+    config.x.streaming_api_base_url = ENV.fetch('STREAMING_API_BASE_URL') { "http#{https ? 's' : ''}://#{web_host}" }
   end
 end
diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb
index 3660c4a9b..dd7fa112e 100644
--- a/config/initializers/redis.rb
+++ b/config/initializers/redis.rb
@@ -1,8 +1,22 @@
 # frozen_string_literal: true
 
+if ENV['REDIS_URL'].blank?
+  password = ENV.fetch('REDIS_PASSWORD') { '' }
+  host     = ENV.fetch('REDIS_HOST') { 'localhost' }
+  port     = ENV.fetch('REDIS_PORT') { 6379 }
+  db       = ENV.fetch('REDIS_DB') { 0 }
+
+  ENV['REDIS_URL'] = "redis://#{password.blank? ? '' : ":#{password}@"}#{host}:#{port}/#{db}"
+end
+
 Redis.current = Redis.new(
-  host: ENV.fetch('REDIS_HOST') { 'localhost' },
-  port: ENV.fetch('REDIS_PORT') { 6379 },
-  password: ENV.fetch('REDIS_PASSWORD') { false },
+  url: ENV['REDIS_URL'],
   driver: :hiredis
 )
+
+Rails.application.configure do
+  config.cache_store = :redis_store, ENV['REDIS_URL'], {
+    namespace: 'cache',
+    expires_in: 10.minutes,
+  }
+end
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 8ae3bd5a2..3d2e4741d 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -1,12 +1,9 @@
-host = ENV.fetch('REDIS_HOST') { 'localhost' }
-port = ENV.fetch('REDIS_PORT') { 6379 }
-password = ENV.fetch('REDIS_PASSWORD') { false }
-db = ENV.fetch('REDIS_DB') { 0 }
+# frozen_string_literal: true
 
 Sidekiq.configure_server do |config|
-  config.redis = { host: host, port: port, db: db, password: password }
+  config.redis = { url: ENV['REDIS_URL'] }
 end
 
 Sidekiq.configure_client do |config|
-  config.redis = { host: host, port: port, db: db, password: password }
+  config.redis = { url: ENV['REDIS_URL'] }
 end