Sha256: d8c837728d445c6b8197959195e5a509b401aca2e9f4708bf5cb40cddb2fc8ea
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
# encoding: utf-8 ## # HireFire # This is a HireFire modified version of # the official Resque::Worker class module ::Resque class Worker def work(interval = 5.0, &block) interval = Float(interval) $0 = "resque: Starting" startup loop do break if shutdown? ::Resque::Job.environment.hire if not @paused and job = reserve log "got: #{job.inspect}" run_hook :before_fork, job working_on job if @child = fork rand # Reseeding procline "Forked #{@child} at #{Time.now.to_i}" Process.wait else procline "Processing #{job.queue} since #{Time.now.to_i}" perform(job, &block) exit! unless @cant_fork end done_working @child = nil else ## # HireFire Hook # After the last job in the queue finishes processing, Resque::Job.jobs will return 0. # This means that there aren't any more jobs to process for any of the workers. # If this is the case it'll command the current environment to fire all the hired workers # and then immediately break out of this infinite loop. if (::Resque::Job.jobs + ::Resque::Job.working) == 0 ::Resque::Job.environment.fire break else sleep(interval) end end end ensure unregister_worker end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hirefire-0.1.3 | lib/hirefire/workers/resque/worker.rb |
hirefire-0.1.2 | lib/hirefire/workers/resque/worker.rb |