[deploy] Feature:Use Sidekiq to Run Scheduled Jobs (#9789)

This commit is contained in:
Molly Struve 2020-08-14 14:44:31 -05:00 committed by GitHub
parent 0a64ac067b
commit 05abf3839c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 0 deletions

View file

@ -91,6 +91,7 @@ gem "rubyzip", "~> 2.3" # Rubyzip is a ruby library for reading and writing zip
gem "s3_direct_upload", "~> 0.1" # Direct Upload to Amazon S3
gem "sassc-rails", "~> 2.1.2" # Integrate SassC-Ruby into Rails
gem "sidekiq", "~> 6.1.1" # Sidekiq is used to process background jobs with the help of Redis
gem "sidekiq-cron", "~> 1.1" # Allows execution of scheduled cron jobs as specific times
gem "sidekiq-unique-jobs", "~> 6.0.22" # Ensures that Sidekiq jobs are unique when enqueued
gem "simpleidn", "~> 0.1" # Convert IDN domains to Punycode
gem "sitemap_generator", "~> 6.1" # SitemapGenerator is a framework-agnostic XML Sitemap generator

View file

@ -283,6 +283,8 @@ GEM
smart_properties
errbase (0.2.0)
erubi (1.9.0)
et-orbi (1.2.4)
tzinfo
eventmachine (1.2.5)
excon (0.75.0)
execjs (2.7.0)
@ -345,6 +347,9 @@ GEM
nokogiri (>= 1.5.11, < 2.0.0)
formatador (0.2.5)
front_matter_parser (0.2.1)
fugit (1.3.8)
et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.3)
gemoji (4.0.0.rc2)
geocoder (1.6.3)
get_process_mem (0.2.5)
@ -549,6 +554,7 @@ GEM
jwt (~> 2.1, >= 2.1.0)
rest-client (~> 2.0, >= 2.0.2)
pusher-signature (0.1.8)
raabro (1.3.1)
rack (2.2.3)
rack-attack (6.3.1)
rack (>= 1.0, < 3)
@ -728,6 +734,9 @@ GEM
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sidekiq-cron (1.2.0)
fugit (~> 1.1)
sidekiq (>= 4.2.1)
sidekiq-unique-jobs (6.0.22)
concurrent-ruby (~> 1.0, >= 1.0.5)
sidekiq (>= 4.0, < 7.0)
@ -968,6 +977,7 @@ DEPENDENCIES
sdoc (~> 1.1)
shoulda-matchers (~> 4.3.0)
sidekiq (~> 6.1.1)
sidekiq-cron (~> 1.1)
sidekiq-unique-jobs (~> 6.0.22)
simplecov (= 0.17.1)
simpleidn (~> 0.1)

View file

@ -5,6 +5,12 @@ Rails.application.config.to_prepare do
end
Sidekiq.configure_server do |config|
schedule_file = "config/schedule.yml"
if File.exist?(schedule_file)
Sidekiq::Cron::Job.load_from_hash(YAML.load_file(schedule_file))
end
sidekiq_url = ApplicationConfig["REDIS_SIDEKIQ_URL"] || ApplicationConfig["REDIS_URL"]
# On Heroku this configuration is overridden and Sidekiq will point at the redis
# instance given by the ENV variable REDIS_PROVIDER

View file

@ -18,6 +18,7 @@ Rails.application.routes.draw do
require "sidekiq/web"
require "sidekiq_unique_jobs/web"
require "sidekiq/cron/web"
authenticated :user, ->(user) { user.tech_admin? } do
Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]

3
config/schedule.yml Normal file
View file

@ -0,0 +1,3 @@
log_worker_queue_stats:
cron: "*/10 * * * *"
class: "Metrics::RecordBackgroundQueueStatsWorker"

BIN
vendor/cache/et-orbi-1.2.4.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/fugit-1.3.8.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/raabro-1.3.1.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/sidekiq-cron-1.2.0.gem vendored Normal file

Binary file not shown.