delayed_jobs_settings_reset.rb 607 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'delayed_job'
  3. class ResetSettingsPlugin < Delayed::Plugin
  4. callbacks do |lifecycle|
  5. lifecycle.before(:invoke_job) do |*_args|
  6. Rails.logger.debug { 'Resetting Settings before Job execution' }
  7. # reload all settings before starting a job
  8. # otherwise it might be that changed settings
  9. # from other processes (e.g. Rails server)
  10. # are reflected and obsolete, cached values
  11. # are wrongfully used
  12. Setting.reload
  13. end
  14. end
  15. end
  16. Delayed::Worker.plugins << ResetSettingsPlugin