Merge pull request #9519 from demarches-simplifiees/init_sidekiq
Tech: infrastructure pour utiliser sidekiq
This commit is contained in:
commit
fcec4a7ef7
8 changed files with 64 additions and 1 deletions
1
Gemfile
1
Gemfile
|
@ -86,6 +86,7 @@ gem 'sentry-delayed_job'
|
|||
gem 'sentry-rails'
|
||||
gem 'sentry-ruby'
|
||||
gem 'sib-api-v3-sdk'
|
||||
gem 'sidekiq'
|
||||
gem 'skylight'
|
||||
gem 'spreadsheet_architect'
|
||||
gem 'strong_migrations' # lint database migrations
|
||||
|
|
|
@ -570,7 +570,7 @@ GEM
|
|||
redcarpet (3.6.0)
|
||||
redis (5.0.6)
|
||||
redis-client (>= 0.9.0)
|
||||
redis-client (0.14.1)
|
||||
redis-client (0.18.0)
|
||||
connection_pool
|
||||
regexp_parser (2.8.1)
|
||||
request_store (1.5.0)
|
||||
|
@ -690,6 +690,11 @@ GEM
|
|||
sib-api-v3-sdk (7.4.0)
|
||||
json (~> 2.1, >= 2.1.0)
|
||||
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)
|
||||
nokogiri
|
||||
rubyzip
|
||||
|
@ -922,6 +927,7 @@ DEPENDENCIES
|
|||
sentry-ruby
|
||||
shoulda-matchers
|
||||
sib-api-v3-sdk
|
||||
sidekiq
|
||||
simple_xlsx_reader
|
||||
skylight
|
||||
spreadsheet_architect
|
||||
|
|
|
@ -19,6 +19,11 @@ Vous souhaitez y apporter des changements ou des améliorations ? Lisez notre [
|
|||
- postgresql
|
||||
- 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
|
||||
|
||||
- rbenv : voir https://github.com/rbenv/rbenv-installer#rbenv-installer--doctor-scripts
|
||||
|
|
8
app/jobs/sidekiq_again_job.rb
Normal file
8
app/jobs/sidekiq_again_job.rb
Normal 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
|
|
@ -24,6 +24,7 @@ as defined by the routes in the `admin/` namespace
|
|||
<hr />
|
||||
|
||||
<%= 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 "Features", manager_flipper_path, class: "navigation__link" %>
|
||||
<%= link_to "Annonces", super_admins_release_notes_path, class: "navigation__link" %>
|
||||
|
|
|
@ -229,6 +229,16 @@ REDIS_CACHE_URL=""
|
|||
REDIS_CACHE_SSL="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
|
||||
# can be debug, info, warn, error, fatal, and unknown
|
||||
DS_LOG_LEVEL='info'
|
||||
|
|
29
config/initializers/sidekiq.rb
Normal file
29
config/initializers/sidekiq.rb
Normal 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
|
|
@ -1,3 +1,5 @@
|
|||
require 'sidekiq/web'
|
||||
|
||||
Rails.application.routes.draw do
|
||||
# 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
|
||||
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
|
||||
mount MaintenanceTasks::Engine => "/maintenance_tasks"
|
||||
mount Sidekiq::Web => "/sidekiq"
|
||||
end
|
||||
|
||||
get 'import_procedure_tags' => 'procedures#import_data'
|
||||
|
|
Loading…
Reference in a new issue