delayed_jobs_settings_reset.rb 530 B

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