Introduce Sidekiq For Background Jobs (#5252)
* Introduce Sidekiq to the app and update RateLimitCheckerJob to use it * fix rate limit checker spec with new sidekiq syntax * add Sidekiq to tech stack overview * Remove RateLimitChecker job change, add sidekiq web UI and testing support
This commit is contained in:
parent
fa9acf2073
commit
2e661809b6
9 changed files with 22 additions and 2 deletions
3
Envfile
3
Envfile
|
|
@ -40,6 +40,9 @@ variable :REDIS_SESSIONS_URL, :String, default: "redis://localhost:6379"
|
|||
variable :SESSION_KEY, :String, default: "_Dev_Community_Session"
|
||||
variable :SESSION_EXPIRY_SECONDS, :Integer, default: 1209600 # two weeks in seconds
|
||||
|
||||
# Redis Sidekiq storage
|
||||
variable :REDIS_SIDEKIQ_URL, :String, default: "redis://localhost:6379"
|
||||
|
||||
################################################
|
||||
############## 3rd Party Services ##############
|
||||
################################################
|
||||
|
|
|
|||
1
Gemfile
1
Gemfile
|
|
@ -82,6 +82,7 @@ gem "rouge", "~> 3.14" # A pure-ruby code highlighter
|
|||
gem "rubyzip", "~> 2.0" # Rubyzip is a ruby library for reading and writing zip files
|
||||
gem "s3_direct_upload", "~> 0.1" # Direct Upload to Amazon S3
|
||||
gem "sass-rails", "~> 6.0" # Sass adapter for the Rails asset pipeline
|
||||
gem "sidekiq", "~> 6.0.4" # Sidekiq is used to process background jobs with the help of Redis
|
||||
gem "sitemap_generator", "~> 6.0" # SitemapGenerator is a framework-agnostic XML Sitemap generator
|
||||
gem "skylight", "~> 4.2" # Skylight is a smart profiler for Rails, Sinatra, and other Ruby apps
|
||||
gem "slack-notifier", "~> 2.3" # A slim ruby wrapper for posting to slack webhooks
|
||||
|
|
|
|||
|
|
@ -723,6 +723,11 @@ GEM
|
|||
shellany (0.0.1)
|
||||
shoulda-matchers (4.1.2)
|
||||
activesupport (>= 4.2.0)
|
||||
sidekiq (6.0.4)
|
||||
connection_pool (>= 2.2.2)
|
||||
rack (>= 2.0.0)
|
||||
rack-protection (>= 2.0.0)
|
||||
redis (>= 4.1.0)
|
||||
signet (0.12.0)
|
||||
addressable (~> 2.3)
|
||||
faraday (~> 0.9)
|
||||
|
|
@ -966,6 +971,7 @@ DEPENDENCIES
|
|||
sass-rails (~> 6.0)
|
||||
sdoc (~> 1.0)
|
||||
shoulda-matchers (= 4.1.2)
|
||||
sidekiq (~> 6.0.4)
|
||||
simplecov (~> 0.17)
|
||||
sitemap_generator (~> 6.0)
|
||||
skylight (~> 4.2)
|
||||
|
|
|
|||
1
Procfile
1
Procfile
|
|
@ -1,3 +1,4 @@
|
|||
release: STATEMENT_TIMEOUT=180000 bundle exec rails db:migrate
|
||||
web: bin/start-pgbouncer bundle exec puma -C config/puma.rb
|
||||
worker: bundle exec rails jobs:work
|
||||
sidekiq_worker: bundle exec sidekiq -t 25
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
web: bin/rails s -p 3000
|
||||
webpacker: ./bin/webpack-dev-server
|
||||
job: bin/rake jobs:work
|
||||
sidekiq: bundle exec sidekiq
|
||||
|
|
|
|||
4
config/initializers/sidekiq.rb
Normal file
4
config/initializers/sidekiq.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Sidekiq.configure_server do |config|
|
||||
sidekiq_url = ApplicationConfig["REDIS_SIDEKIQ_URL"] || ApplicationConfig["REDIS_URL"]
|
||||
config.redis = { url: sidekiq_url }
|
||||
end
|
||||
|
|
@ -10,8 +10,10 @@ Rails.application.routes.draw do
|
|||
registrations: "registrations"
|
||||
}
|
||||
|
||||
require "sidekiq/web"
|
||||
authenticated :user, ->(user) { user.tech_admin? } do
|
||||
mount DelayedJobWeb, at: "/delayed_job"
|
||||
mount Sidekiq::Web => "/sidekiq"
|
||||
end
|
||||
|
||||
devise_scope :user do
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ For the Dev.to tech stack we use:
|
|||
- [_Honeybadger_](https://www.honeybadger.io/) for error monitoring
|
||||
- [_Timber_](https://timber.io/) for logging
|
||||
- [_Delayed Job_](https://github.com/collectiveidea/delayed_job) and
|
||||
[_Active Job_](https://guides.rubyonrails.org/active_job_basics.html) for
|
||||
background workers
|
||||
- [_Sidekiq_](https://github.com/mperham/sidekiq) (will be replacing delayed
|
||||
job) and [_Active Job_](https://guides.rubyonrails.org/active_job_basics.html)
|
||||
for background workers
|
||||
- [_Algolia_](https://www.algolia.com/) for search
|
||||
- [_Redcarpet_](https://github.com/vmg/redcarpet) and
|
||||
[_Rouge_](https://github.com/jneen/rouge) to parse Markdown
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ require "webmock/rspec"
|
|||
require "test_prof/recipes/rspec/before_all"
|
||||
require "test_prof/recipes/rspec/let_it_be"
|
||||
require "test_prof/recipes/rspec/sample"
|
||||
require "sidekiq/testing"
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue