module DelayedJobActivityMonitoring

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`

Public Instance Methods

work_off(num = 100) click to toggle source
Calls superclass method
# File lib/roqua/core_ext/delayed_job/activity_monitoring.rb, line 13
def work_off(num = 100)
  FileUtils.touch(Rails.root.join('tmp', 'delayed_job_activity'))
  super(num)
end

Protected Instance Methods

reserve_job() click to toggle source
Calls superclass method
# File lib/roqua/core_ext/delayed_job/activity_monitoring.rb, line 20
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