add sidekiq initializer

This commit is contained in:
simon lehericey 2023-09-26 12:31:26 +02:00
parent 8ef3b77c0e
commit 9cd165635d
3 changed files with 44 additions and 0 deletions

View file

@ -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

View file

@ -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'

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