module Resque::Durable::Monitor

Attributes

auditor[RW]
expiration[RW]
wait_duration[RW]

Public Class Methods

new(auditor) click to toggle source
# File lib/resque/durable/monitor.rb, line 7
def initialize(auditor)
  @auditor = auditor
end

Public Instance Methods

install_signal_handlers() click to toggle source
# File lib/resque/durable/monitor.rb, line 34
def install_signal_handlers
  trap('TERM') { stop }
  trap('INT')  { stop }
end
run() click to toggle source
# File lib/resque/durable/monitor.rb, line 16
def run
  install_signal_handlers

  loop do
    watch
    wait
    break if @stopped
  end
end
stop() click to toggle source
# File lib/resque/durable/monitor.rb, line 39
def stop
  puts 'Stopping...'
  @stopped = true
end
wait() click to toggle source
# File lib/resque/durable/monitor.rb, line 26
def wait
  sleep(wait_duration)
end
watch() click to toggle source
# File lib/resque/durable/monitor.rb, line 11
def watch
  auditor.recover
  auditor.cleanup(expiration.ago)
end