Skip to content

Commit

Permalink
feat!: install Sidekiq task queue
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires worker+redis on Heroku; new gems; new env vars
  • Loading branch information
blms committed Sep 24, 2021
1 parent 13b15b1 commit 9c1c04a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ SECRET_KEY_BASE=
# DM2_DATABASE_USER=
# DM2_DATABASE_PASSWORD=

## Database credentials to use on this production instance
# DM2_DATABASE_USER=testuser
# DM2_DATABASE_PASSWORD=testpassword

## Redis URL
# REDIS_URL=redis://localhost:6379

## Must be set to REDIS_URL
# REDIS_PROVIDER=REDIS_URL

# -----------------------------------------------------------------------------
# Required for running Docker Compose in a production environment
# -----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ gem 'pg_search'
gem 'figaro'
gem 'open-uri'
gem 'storyblok-richtext-renderer', github: 'performant-software/storyblok-ruby-richtext-renderer', ref: '0a6c2e8e81560311569d49d06c0e32abd0effcd5'
gem 'sidekiq', '~>6.0.0'
gem 'sidekiq-status'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ GEM
byebug (11.1.3)
case_transform (0.2)
activesupport
chronic_duration (0.10.6)
numerizer (~> 0.1.1)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
crass (1.0.6)
devise (4.7.3)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -124,6 +127,7 @@ GEM
nokogiri (1.12.3)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
numerizer (0.1.1)
open-uri (0.1.0)
orm_adapter (0.5.0)
pg (1.2.3)
Expand All @@ -137,6 +141,8 @@ GEM
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-protection (2.1.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.6)
Expand Down Expand Up @@ -167,12 +173,21 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.4.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
ruby-vips (2.1.3)
ffi (~> 1.12)
ruby_dep (1.5.0)
sidekiq (6.0.7)
connection_pool (>= 2.2.2)
rack (~> 2.0)
rack-protection (>= 2.0.0)
redis (>= 4.1.0)
sidekiq-status (2.1.0)
chronic_duration
sidekiq (>= 5.0)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -215,6 +230,8 @@ DEPENDENCIES
puma (~> 4.3)
rack-cors
rails (~> 5.2.0)
sidekiq (~> 6.0.0)
sidekiq-status
spring
spring-watcher-listen (~> 2.0.0)
storyblok-richtext-renderer!
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
release: rails db:migrate
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -e production -C config/sidekiq.yml
1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ production:
database: dm2_production
username: <%= ENV['DM2_DATABASE_USER'] %>
password: <%= ENV['DM2_DATABASE_PASSWORD'] %>
url: <%= ENV['DATABASE_URL'] %>
11 changes: 11 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'sidekiq'
require 'sidekiq-status'

Sidekiq.configure_client do |config|
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
end

Sidekiq.configure_server do |config|
Sidekiq::Status.configure_server_middleware config, expiration: 30.minutes
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
end
8 changes: 8 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
:concurrency: 2
staging:
:concurrency: 5
production:
:concurrency: 5
:queues:
- default

0 comments on commit 9c1c04a

Please sign in to comment.