Merge pull request #9519 from demarches-simplifiees/init_sidekiq

Tech: infrastructure pour utiliser sidekiq
This commit is contained in:
LeSim 2023-11-09 16:18:04 +00:00 committed by GitHub
commit fcec4a7ef7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 64 additions and 1 deletions

View file

@ -86,6 +86,7 @@ gem 'sentry-delayed_job'
gem 'sentry-rails' gem 'sentry-rails'
gem 'sentry-ruby' gem 'sentry-ruby'
gem 'sib-api-v3-sdk' gem 'sib-api-v3-sdk'
gem 'sidekiq'
gem 'skylight' gem 'skylight'
gem 'spreadsheet_architect' gem 'spreadsheet_architect'
gem 'strong_migrations' # lint database migrations gem 'strong_migrations' # lint database migrations

View file

@ -570,7 +570,7 @@ GEM
redcarpet (3.6.0) redcarpet (3.6.0)
redis (5.0.6) redis (5.0.6)
redis-client (>= 0.9.0) redis-client (>= 0.9.0)
redis-client (0.14.1) redis-client (0.18.0)
connection_pool connection_pool
regexp_parser (2.8.1) regexp_parser (2.8.1)
request_store (1.5.0) request_store (1.5.0)
@ -690,6 +690,11 @@ GEM
sib-api-v3-sdk (7.4.0) sib-api-v3-sdk (7.4.0)
json (~> 2.1, >= 2.1.0) json (~> 2.1, >= 2.1.0)
typhoeus (~> 1.0, >= 1.0.1) typhoeus (~> 1.0, >= 1.0.1)
sidekiq (7.2.0)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
simple_xlsx_reader (1.0.4) simple_xlsx_reader (1.0.4)
nokogiri nokogiri
rubyzip rubyzip
@ -922,6 +927,7 @@ DEPENDENCIES
sentry-ruby sentry-ruby
shoulda-matchers shoulda-matchers
sib-api-v3-sdk sib-api-v3-sdk
sidekiq
simple_xlsx_reader simple_xlsx_reader
skylight skylight
spreadsheet_architect spreadsheet_architect

View file

@ -19,6 +19,11 @@ Vous souhaitez y apporter des changements ou des améliorations ? Lisez notre [
- postgresql - postgresql
- imagemagick et gsfonts pour générer les filigranes sur les titres d'identité. - imagemagick et gsfonts pour générer les filigranes sur les titres d'identité.
nous sommes en cours de migration de delayed_job vers sidekiq pour le traitement des jobs asynchrones.
pour faire tourner sidekiq, vous aurez besoin de
- redis
#### Développement #### Développement
- rbenv : voir https://github.com/rbenv/rbenv-installer#rbenv-installer--doctor-scripts - rbenv : voir https://github.com/rbenv/rbenv-installer#rbenv-installer--doctor-scripts

View file

@ -0,0 +1,8 @@
class SidekiqAgainJob < ApplicationJob
self.queue_adapter = :sidekiq
queue_as :default
def perform(user)
UserMailer.new_account_warning(user).deliver_now
end
end

View file

@ -24,6 +24,7 @@ as defined by the routes in the `admin/` namespace
<hr /> <hr />
<%= link_to "Delayed Jobs", manager_delayed_job_path, class: "navigation__link" %> <%= link_to "Delayed Jobs", manager_delayed_job_path, class: "navigation__link" %>
<%= link_to "Sidekiq", manager_sidekiq_web_path, class: "navigation__link" %>
<%= link_to "Maintenance Tasks", manager_maintenance_tasks_path, class: "navigation__link" %> <%= link_to "Maintenance Tasks", manager_maintenance_tasks_path, class: "navigation__link" %>
<%= link_to "Features", manager_flipper_path, class: "navigation__link" %> <%= link_to "Features", manager_flipper_path, class: "navigation__link" %>
<%= link_to "Annonces", super_admins_release_notes_path, class: "navigation__link" %> <%= link_to "Annonces", super_admins_release_notes_path, class: "navigation__link" %>

View file

@ -229,6 +229,16 @@ REDIS_CACHE_URL=""
REDIS_CACHE_SSL="enabled" REDIS_CACHE_SSL="enabled"
REDIS_CACHE_SSL_VERIFY_NONE="enabled" REDIS_CACHE_SSL_VERIFY_NONE="enabled"
# configuration for sidekiq's redis
# simple mode
# that's all you need to do to conf your sidekiq on a local redis
REDIS_URL="redis://localhost:6379"
# or sentinels mode
REDIS_SIDEKIQ_SENTINELS='sentinel://host-1:26379,sentinel://host-2:26379'
REDIS_SIDEKIQ_MASTER='master_name'
REDIS_SIDEKIQ_PASSWORD='sentinel_and_redis_password'
REDIS_SIDEKIQ_USERNAME='sentinel_and_redis_username'
# Setup log level, info if nil # Setup log level, info if nil
# can be debug, info, warn, error, fatal, and unknown # can be debug, info, warn, error, fatal, and unknown
DS_LOG_LEVEL='info' DS_LOG_LEVEL='info'

View file

@ -0,0 +1,29 @@
if ENV.has_key?('REDIS_SIDEKIQ_SENTINELS')
name = ENV.fetch('REDIS_SIDEKIQ_MASTER')
username = ENV.fetch('REDIS_SIDEKIQ_USERNAME')
password = ENV.fetch('REDIS_SIDEKIQ_PASSWORD')
sentinels = ENV.fetch('REDIS_SIDEKIQ_SENTINELS')
.split(',')
.map { URI.parse(_1) }
.map { { host: _1.host, port: _1.port, username:, password: } }
Sidekiq.configure_server do |config|
config.redis = {
name:,
sentinels:,
username:,
password:,
role: :master
}
end
Sidekiq.configure_client do |config|
config.redis = {
name:,
sentinels:,
username:,
password:,
role: :master
}
end
end

View file

@ -1,3 +1,5 @@
require 'sidekiq/web'
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
@ -95,6 +97,7 @@ Rails.application.routes.draw do
mount Flipper::UI.app(-> { Flipper.instance }) => "/features", as: :flipper mount Flipper::UI.app(-> { Flipper.instance }) => "/features", as: :flipper
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post] match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
mount MaintenanceTasks::Engine => "/maintenance_tasks" mount MaintenanceTasks::Engine => "/maintenance_tasks"
mount Sidekiq::Web => "/sidekiq"
end end
get 'import_procedure_tags' => 'procedures#import_data' get 'import_procedure_tags' => 'procedures#import_data'