Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

don't exit the job polling loop unless the environment says so

  • Loading branch information...
commit 948fee885acc33a69cd0d294aa079672da642300 1 parent 984c377
@igorbernstein igorbernstein authored
View
6 lib/hirefire/environment/base.rb
@@ -163,12 +163,16 @@ def hire
# If there are workers active, but there are no more pending jobs,
# then fire all the workers or set to the minimum_workers
#
- # @return [nil]
+ # @return [Boolean] if the workers have been fired
def fire
if jobs == 0 and workers > min_workers
Logger.message("All queued jobs have been processed. " + (min_workers > 0 ? "Setting workers to #{min_workers}." : "Firing all workers."))
workers(min_workers)
+
+ return true
end
+
+ return false
end
private
View
3  lib/hirefire/workers/delayed_job/worker.rb
@@ -59,8 +59,7 @@ def start
# 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 queued.jobs == 0
- Delayed::Job.environment.fire
- break
+ break if Delayed::Job.environment.fire
end
break if $exit
View
7 lib/hirefire/workers/resque/worker.rb
@@ -41,12 +41,11 @@ def work(interval = 5.0, &block)
# 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)
+ break if ::Resque::Job.environment.fire
end
+ sleep(interval)
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.