From ab8ac78ccb46446f6bed23c8fff0623bf9c1141e Mon Sep 17 00:00:00 2001 From: mfo Date: Thu, 3 Oct 2024 11:13:33 +0200 Subject: [PATCH] tech(sidekiq): use sidekiq by default, clean transition code --- Procfile.dev | 2 +- app/jobs/sidekiq_again_job.rb | 14 -------- config/env.example.optional | 3 ++ config/environments/production.rb | 2 +- config/initializers/transition_to_sidekiq.rb | 35 -------------------- 5 files changed, 5 insertions(+), 51 deletions(-) delete mode 100644 app/jobs/sidekiq_again_job.rb delete mode 100644 config/initializers/transition_to_sidekiq.rb diff --git a/Procfile.dev b/Procfile.dev index 953087cec..1459bc6df 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,3 @@ -web: RAILS_QUEUE_ADAPTER=delayed_job bin/rails server -p 3000 +web: bin/rails server -p 3000 jobs: bin/rake jobs:work vite: bin/vite dev diff --git a/app/jobs/sidekiq_again_job.rb b/app/jobs/sidekiq_again_job.rb deleted file mode 100644 index dcb7b4059..000000000 --- a/app/jobs/sidekiq_again_job.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class SidekiqAgainJob < ApplicationJob - self.queue_adapter = :sidekiq - queue_as :default - - def perform(user, with_exception: false) - if with_exception - raise 'Nop' - end - Sentry.capture_message('this is a message from sidekiq') - UserMailer.new_account_warning(user).deliver_now - end -end diff --git a/config/env.example.optional b/config/env.example.optional index 74451810a..050e5d49b 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -282,3 +282,6 @@ VITE_LIGHTGALLERY_LICENSE_KEY = "" # This email will be visible to users whom dossier had been fixed by our maintenance_tasks # By default we use CONTACT_EMAIL, but you can customize it MAINTENANCE_INSTRUCTEUR_EMAIL="" + +# want to stay on delayed job ? set as 'delayed_job' +RAILS_QUEUE_ADAPTER=" \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index eb1d964eb..cf942cd6c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -83,7 +83,7 @@ Rails.application.configure do end # Use a real queuing backend for Active Job (and separate queues per environment). - config.active_job.queue_adapter = :delayed_job + config.active_job.queue_adapter = ENV.fetch('RAILS_QUEUE_ADAPTER') { :sidekiq } # config.active_job.queue_name_prefix = "tps_production" config.action_mailer.perform_caching = false diff --git a/config/initializers/transition_to_sidekiq.rb b/config/initializers/transition_to_sidekiq.rb deleted file mode 100644 index a60869ac1..000000000 --- a/config/initializers/transition_to_sidekiq.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -if Rails.env.production? && SIDEKIQ_ENABLED - ActiveSupport.on_load(:after_initialize) do - [ - ActiveStorage::AnalyzeJob, - ActiveStorage::PurgeJob, - AdminUpdateDefaultZonesJob, - APIEntreprise::Job, - AdminUpdateDefaultZonesJob, - BatchOperationEnqueueAllJob, - BatchOperationProcessOneJob, - ChampFetchExternalDataJob, - Cron::CronJob, - DestroyRecordLaterJob, - DossierIndexSearchTermsJob, - DossierOperationLogMoveToColdStorageBatchJob, - DossierRebaseJob, - HelpscoutCreateConversationJob, - ImageProcessorJob, - MaintenanceTasks::TaskJob, - Migrations::BackfillStableIdJob, - PriorizedMailDeliveryJob, - ProcedureExternalURLCheckJob, - ProcedureSVASVRProcessDossierJob, - ProcessStalledDeclarativeDossierJob, - ResetExpiringDossiersJob, - SendClosingNotificationJob, - VirusScannerJob, - WebHookJob - ].each do |job_class| - job_class.queue_adapter = :sidekiq - end - end -end