From 18d7316f1dd298427c44aad0d221b71602a2b70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Thu, 31 Dec 2020 11:53:57 +0100 Subject: [PATCH] Ajout de Sidekiq pour traiter les queues --- Gemfile | 1 + Gemfile.lock | 7 +++++++ config/application.rb | 2 ++ config/routes.rb | 3 +++ config/sidekiq.yml | 13 +++++++++++++ 5 files changed, 26 insertions(+) create mode 100644 config/sidekiq.yml diff --git a/Gemfile b/Gemfile index af4b3f0..18ccae1 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ gem 'jbuilder', '~> 2.7' gem 'elasticsearch-persistence' gem 'elasticsearch-rails' +gem 'sidekiq' # gem 'dry-types' gem 'dry-struct' diff --git a/Gemfile.lock b/Gemfile.lock index e550805..02b3389 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,6 +78,7 @@ GEM childprocess (3.0.0) coderay (1.1.3) concurrent-ruby (1.1.7) + connection_pool (2.2.3) crass (1.0.6) dry-configurable (0.11.6) concurrent-ruby (~> 1.0) @@ -200,6 +201,7 @@ GEM rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) + redis (4.2.5) regexp_parser (1.8.2) ruby2_keywords (0.0.2) rubyzip (2.3.0) @@ -216,6 +218,10 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) + sidekiq (6.1.2) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) @@ -272,6 +278,7 @@ DEPENDENCIES rails (~> 6.1.0) sass-rails (>= 6) selenium-webdriver + sidekiq spring spring-watcher-listen (~> 2.0.0) sqlite3 (~> 1.4) diff --git a/config/application.rb b/config/application.rb index 4d74159..63ad398 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,6 +12,8 @@ module Evobal # Initialize configuration defaults for originally generated Rails version. config.load_defaults 6.0 + config.active_job.queue_adapter = :sidekiq + # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading diff --git a/config/routes.rb b/config/routes.rb index 0f13cee..d569ccb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ +require 'sidekiq/web' + Rails.application.routes.draw do resources :emails # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html + mount Sidekiq::Web => '/sidekiq' end diff --git a/config/sidekiq.yml b/config/sidekiq.yml new file mode 100644 index 0000000..08c7f1d --- /dev/null +++ b/config/sidekiq.yml @@ -0,0 +1,13 @@ +--- + +:concurrency: 2 +staging: + :concurrency: 10 +production: + :concurrency: 20 +:queues: + - default + - mailers + - action_mailbox_routing + - active_storage_analysis + - action_mailbox_incineration