From 5360c919d246d54d86e7eb4d25f5332e1c9279cc Mon Sep 17 00:00:00 2001 From: shaojunda Date: Wed, 27 Nov 2019 11:44:10 +0800 Subject: [PATCH] feat: add background job related gems --- Gemfile | 14 ++++++++++---- Gemfile.lock | 23 ++++++++++++++++++++++- config/routes.rb | 1 + config/sidekiq.yml | 11 ++++------- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index a78a984b1..44a26fc6f 100644 --- a/Gemfile +++ b/Gemfile @@ -44,10 +44,16 @@ gem "ckb-sdk-ruby", git: "https://github.com/nervosnetwork/ckb-sdk-ruby.git", re gem "hiredis", "~> 0.6.1" gem "redis", "~> 4.0", ">= 4.0.3" -# Sidekiq -gem "sidekiq", "~> 5.2", ">= 5.2.3" -gem "sidekiq-unique-jobs" -gem "sidekiq-failures" +# Backgroud Jobs + +group :production, :staging, :development do + gem "sidekiq" + gem "sidekiq-statistic" + gem "sidekiq-cron" + gem "sidekiq-unique-jobs" + gem "sidekiq-status" + gem "sidekiq-failures" +end # bulk insertion of data into database using ActiveRecord gem "activerecord-import" diff --git a/Gemfile.lock b/Gemfile.lock index 7f6a4d744..d97afa4f4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,6 +94,8 @@ GEM bootsnap (1.4.4) msgpack (~> 1.0) builder (3.2.3) + chronic_duration (0.10.6) + numerizer (~> 0.1.1) codecov (0.1.14) json simplecov @@ -146,6 +148,8 @@ GEM dry-types (~> 0.14.0) equatable (0.5.0) erubi (1.8.0) + et-orbi (1.2.2) + tzinfo factory_bot (5.0.2) activesupport (>= 4.2.0) factory_bot_rails (5.0.2) @@ -154,6 +158,9 @@ GEM fast_jsonapi (1.5) activesupport (>= 4.2) ffi (1.11.2) + fugit (1.3.3) + et-orbi (~> 1.1, >= 1.1.8) + raabro (~> 1.1) globalid (0.4.2) activesupport (>= 4.2.0) hashdiff (0.4.0) @@ -210,6 +217,7 @@ GEM nio4r (2.4.0) nokogiri (1.10.5) mini_portile2 (~> 2.4.0) + numerizer (0.1.1) open4 (1.3.4) parallel (1.17.0) parser (2.6.3.0) @@ -226,6 +234,7 @@ GEM public_suffix (3.1.0) puma (4.1.1) nio4r (~> 2.0) + raabro (1.1.6) rack (2.0.7) rack-accept (0.4.5) rack (>= 0.4) @@ -292,8 +301,17 @@ GEM rack (>= 1.5.0) rack-protection (>= 1.5.0) redis (>= 3.3.5, < 5) + sidekiq-cron (1.1.0) + fugit (~> 1.1) + sidekiq (>= 4.2.1) sidekiq-failures (1.0.0) sidekiq (>= 4.0.0) + sidekiq-statistic (1.4.0) + sidekiq (>= 5.0) + tilt (~> 2.0) + sidekiq-status (1.1.4) + chronic_duration + sidekiq (>= 3.0) sidekiq-unique-jobs (6.0.13) concurrent-ruby (~> 1.0, >= 1.0.5) sidekiq (>= 4.0, < 7.0) @@ -389,8 +407,11 @@ DEPENDENCIES ruby-progressbar shoulda-context shoulda-matchers - sidekiq (~> 5.2, >= 5.2.3) + sidekiq + sidekiq-cron sidekiq-failures + sidekiq-statistic + sidekiq-status sidekiq-unique-jobs simplecov spring diff --git a/config/routes.rb b/config/routes.rb index 0b054f444..d788f20c7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html require "sidekiq/web" require "sidekiq_unique_jobs/web" + require "sidekiq/cron/web" mount Sidekiq::Web => "/sidekiq" root "application#homepage" diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 17713ca23..a9243f0aa 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -1,14 +1,11 @@ --- :concurrency: 5 :queues: - - [inauthentic_sync, 4] - - [tx_fee_updater, 4] - - [block_reward_updater, 4] - - [authentic_sync, 3] - - [transaction_status_updater, 3] + - critical - default + - low production: - :concurrency: 40 + :concurrency: 10 staging: - :concurrency: 15 + :concurrency: 10