Skip to content

Commit

Permalink
Configure Sidekiq
Browse files Browse the repository at this point in the history
This sets up three queues, `mailer`, `analytics` and `default` in that
priority order. I've intentionally left `default` as lowest priority to
encourage the use of named queues.

I've also added a Sidekiq process to the Procfile for production and
development.
  • Loading branch information
thomasleese committed Jun 14, 2022
1 parent 415adf5 commit 396609b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: bin/rails db:migrate && bin/rails server -p ${PORT:-5000} -e $RAILS_ENV
worker: bundle exec sidekiq -C ./config/sidekiq.yml
1 change: 1 addition & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
web: bin/rails server -p 3000
worker: bundle exec sidekiq -C ./config/sidekiq.yml
js: yarn build --watch
css: yarn build:css --watch
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true

config.active_job.queue_adapter = :sidekiq
end
3 changes: 1 addition & 2 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "apply_for_qualified_teacher_status_production"
config.active_job.queue_adapter = :sidekiq

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
Expand Down
4 changes: 2 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

config.action_mailer.delivery_method = :test

config.active_job.queue_adapter = :test

config.action_mailer.delivery_method = :test
end
7 changes: 7 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Sidekiq.configure_server do |config|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
end

Sidekiq.configure_client do |config|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
end
7 changes: 7 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
:verbose: false
:concurrency: 10
:queues:
- mailer
- analytics
- default
1 change: 1 addition & 0 deletions spec/support/active_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RSpec.configure { |config| config.include ActiveJob::TestHelper }

0 comments on commit 396609b

Please sign in to comment.