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:
parent
540eab58e3
commit
49e444d1f6
1 changed files with 20 additions and 0 deletions
20
config/initializers/delayed_jobs_settings_reset.rb
Normal file
20
config/initializers/delayed_jobs_settings_reset.rb
Normal 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
|
Loading…
Reference in a new issue