2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-01-04 14:36:20 +00:00
|
|
|
require 'delayed_job'
|
|
|
|
|
|
|
|
class ResetSettingsPlugin < Delayed::Plugin
|
|
|
|
|
|
|
|
callbacks do |lifecycle|
|
|
|
|
lifecycle.before(:invoke_job) do |*_args|
|
|
|
|
|
2018-03-20 17:47:49 +00:00
|
|
|
Rails.logger.debug { 'Resetting Settings before Job execution' }
|
2018-01-04 14:36:20 +00:00
|
|
|
|
|
|
|
# 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
|