class Qu::Delayed::Worker
Public Instance Methods
handle_signals()
click to toggle source
# File lib/qu/delayed/worker.rb, line 15 def handle_signals logger.debug "Sheduler #{id} registering traps for INT and TERM signals" %W(INT TERM).each do |sig| trap(sig) do logger.info "Sheduler #{id} received #{sig}, shutting down" raise Abort end end end
hostname()
click to toggle source
# File lib/qu/delayed/worker.rb, line 59 def hostname @hostname ||= `hostname`.strip end
id()
click to toggle source
# File lib/qu/delayed/worker.rb, line 51 def id @id ||= "#{hostname}:#{pid}" end
pid()
click to toggle source
# File lib/qu/delayed/worker.rb, line 55 def pid @pid ||= Process.pid end
poll_frequency()
click to toggle source
# File lib/qu/delayed/worker.rb, line 11 def poll_frequency Qu.backend.poll_frequency end
start()
click to toggle source
# File lib/qu/delayed/worker.rb, line 41 def start logger.warn "Sheduler #{id} starting" handle_signals loop { work } rescue Abort => e # Ok, we'll shut down, but give us a sec ensure logger.debug "Sheduler #{id} done" end
work(options = {:block => true})
click to toggle source
# File lib/qu/delayed/worker.rb, line 25 def work(options = {:block => true}) loop do logger.debug { "Getting next delayed job" } if payload = Qu.backend.next_delayed_job return Qu.backend.enqueue(payload) end if options[:block] sleep poll_frequency else break end end end