lib/hirefire/workers/resque.rb in hirefire-0.1.1 vs lib/hirefire/workers/resque.rb in hirefire-0.1.2
- old
+ new
@@ -14,14 +14,15 @@
def self.enqueue(klass, *args)
Job.create(queue_from_class(klass), klass, *args)
##
# HireFire Hook
- # After a new job gets queued, we command the current environment
- # to calculate the amount of workers we need to process the jobs
- # that are currently queued, and hire them accordingly.
- if ::Resque.info[:working].to_i == 0 \
- or ::Resque.info[:jobs] == 1
+ # After a new job gets enqueued we check to see if there are currently
+ # any workers up and running. If this is the case then we do nothing and
+ # let the worker pick up the jobs (and potentially hire more workers)
+ #
+ # If there are no workers, then we manually hire workers.
+ if ::Resque::Job.workers == 0
::Resque::Job.environment.hire
end
Plugin.after_enqueue_hooks(klass).each do |hook|
klass.send(hook, *args)