Added Delayed::Jobs plugin to reset Settings before each job execution to prevent loading of obsolete Setting values from cache.

This commit is contained in:
Thorsten Eckel 2018-01-04 15:36:20 +01:00
parent 540eab58e3
commit 49e444d1f6

View file

@ -0,0 +1,20 @@
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