diff --git a/Gemfile b/Gemfile index 0c98e2a64..e241f02af 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 3b2ecb9ec..b1282bc2a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index c3839de77..3960df437 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index f655e2c11..311d61268 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/config/schedule.yml b/config/schedule.yml new file mode 100644 index 000000000..01d6ad4c9 --- /dev/null +++ b/config/schedule.yml @@ -0,0 +1,3 @@ +log_worker_queue_stats: + cron: "*/10 * * * *" + class: "Metrics::RecordBackgroundQueueStatsWorker" diff --git a/vendor/cache/et-orbi-1.2.4.gem b/vendor/cache/et-orbi-1.2.4.gem new file mode 100644 index 000000000..d74e75b43 Binary files /dev/null and b/vendor/cache/et-orbi-1.2.4.gem differ diff --git a/vendor/cache/fugit-1.3.8.gem b/vendor/cache/fugit-1.3.8.gem new file mode 100644 index 000000000..b8af5ffca Binary files /dev/null and b/vendor/cache/fugit-1.3.8.gem differ diff --git a/vendor/cache/raabro-1.3.1.gem b/vendor/cache/raabro-1.3.1.gem new file mode 100644 index 000000000..d82114cd2 Binary files /dev/null and b/vendor/cache/raabro-1.3.1.gem differ diff --git a/vendor/cache/sidekiq-cron-1.2.0.gem b/vendor/cache/sidekiq-cron-1.2.0.gem new file mode 100644 index 000000000..1cf695a2e Binary files /dev/null and b/vendor/cache/sidekiq-cron-1.2.0.gem differ