trabajo-afectivo/config/initializers/delayed_jobs_settings_reset.rb

23 lines
607 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
require 'delayed_job'
class ResetSettingsPlugin < Delayed::Plugin
callbacks do |lifecycle|
lifecycle.before(:invoke_job) do |*_args|
Rails.logger.debug { 'Resetting Settings before Job execution' }
# reload all settings before starting a job
# otherwise it might be that changed settings
# from other processes (e.g. Rails server)
# are reflected and obsolete, cached values
# are wrongfully used
Setting.reload
end
end
end
Delayed::Worker.plugins << ResetSettingsPlugin