Browse Source

Configure Sidekiq and Rack::Attack to use dedicated Redis instance in PaaS environments (#867)

pull/868/head
James Rose 2 years ago committed by GitHub
parent
commit
d213ab8b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      .rubocop.yml
  2. 2
      config/initializers/rack_attack.rb
  3. 11
      config/initializers/sidekiq.rb
  4. 4
      manifest.yml

7
.rubocop.yml

@ -20,3 +20,10 @@ AllCops:
Style/Documentation: Style/Documentation:
Enabled: false Enabled: false
Rails/UnknownEnv:
Environments:
- production
- staging
- development
- test

2
config/initializers/rack_attack.rb

@ -5,7 +5,7 @@ if Rails.env.development? || Rails.env.test?
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
Rack::Attack.enabled = false Rack::Attack.enabled = false
else else
redis_url = Configuration::PaasConfigurationService.new.redis_uris[:"dluhc-core-#{Rails.env}-redis-rate-limit"] redis_url = Configuration::PaasConfigurationService.new.redis_uris[:"dluhc-core-#{Rails.env}-redis"]
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url) Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: redis_url)
end end

11
config/initializers/sidekiq.rb

@ -0,0 +1,11 @@
if Rails.env.staging? || Rails.env.production?
redis_url = Configuration::PaasConfigurationService.new.redis_uris[:"dluhc-core-#{Rails.env}-redis"]
Sidekiq.configure_server do |config|
config.redis = { url: redis_url }
end
Sidekiq.configure_client do |config|
config.redis = { url: redis_url }
end
end

4
manifest.yml

@ -21,7 +21,7 @@ applications:
RAILS_ENV: staging RAILS_ENV: staging
services: services:
- dluhc-core-staging-postgres - dluhc-core-staging-postgres
- dluhc-core-staging-redis-rate-limit - dluhc-core-staging-redis
- name: dluhc-core-production - name: dluhc-core-production
<<: *defaults <<: *defaults
@ -35,4 +35,4 @@ applications:
host: submit-social-housing-lettings-sales-data host: submit-social-housing-lettings-sales-data
services: services:
- dluhc-core-production-postgres - dluhc-core-production-postgres
- dluhc-core-production-redis-rate-limit - dluhc-core-production-redis

Loading…
Cancel
Save