Sha256: 9bc82cf47cd319df6d7c116543b6d17cdca9fd52c5496de3a564779b8d35c2de
Contents?: true
Size: 971 Bytes
Versions: 16
Compression:
Stored size: 971 Bytes
Contents
require 'delayed_job' # # Updates the modification time of the file $RAILS_ROOT/tmp/delayed_job_activity when # relevant worker activity occurs. To be used for monitoring whether a DelayedJob # worker is still picking up new work in a timely fashion. # # A file based approach is used so it is easy to add a health check to a Docker container # with the following command: # `find /app/tmp -mmin -$MAXIMUM_AGE_OF_FILE_IN_MINUTES -type f -print | grep delayed_job_activity` # module DelayedJobActivityMonitoring def work_off(num = 100) FileUtils.touch(Rails.root.join('tmp', 'delayed_job_activity')) super(num) end protected def reserve_job super.tap do |job| if job FileUtils.touch( Rails.root.join('tmp', 'delayed_job_activity'), mtime: job.max_run_time.from_now ) end end end end Delayed::Worker.send(:prepend, DelayedJobActivityMonitoring) if defined?(Delayed) && defined?(Delayed::Worker)
Version data entries
16 entries across 16 versions & 1 rubygems