lib/rocket_job/worker.rb in rocketjob-1.1.1 vs lib/rocket_job/worker.rb in rocketjob-1.1.2

- old
+ new

@@ -115,15 +115,18 @@ end # Destroy's all instances of zombie workers and requeues any jobs still "running" # on those workers def self.destroy_zombies + count = 0 each do |worker| - next unless zombie? + next unless worker.zombie? logger.warn "Destroying zombie worker #{worker.name}, and requeueing its jobs" worker.destroy + count += 1 end + count end def self.destroy_dead_workers warn 'RocketJob::Worker.destroy_dead_workers is deprecated, use RocketJob::Worker.destroy_zombies' destroy_zombies @@ -218,11 +221,12 @@ # Possible causes for a worker to miss its heartbeats: # - The worker process has died # - The worker process is "hanging" # - The worker is no longer able to communicate with the MongoDB Server def zombie?(missed = 4) + return false unless running? dead_seconds = Config.instance.heartbeat_seconds * missed - (Time.now - worker.heartbeat.updated_at) >= dead_seconds + (Time.now - heartbeat.updated_at) >= dead_seconds end protected def next_worker_id