Module: Resque
- Defined in:
- lib/resque/heartbeat.rb
Defined Under Namespace
Classes: Worker
Class Method Summary collapse
- .dead_workers ⇒ Object
-
.prune_dead_workers! ⇒ Object
NOTE: this assumes all of your workers are putting out heartbeats.
Class Method Details
.dead_workers ⇒ Object
134 135 136 |
# File 'lib/resque/heartbeat.rb', line 134 def self.dead_workers Worker.all.select{|w| w.dead?} end |
.prune_dead_workers! ⇒ Object
NOTE: this assumes all of your workers are putting out heartbeats
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/resque/heartbeat.rb', line 114 def self.prune_dead_workers! begin beats = Resque.redis.keys(Worker::Heart.heartbeat_key('*', '*')) Worker.all.each do |worker| worker.prune_if_dead # remove the worker from consideration beats.delete worker.heart.key end # at this point, beats only contains stuff from workers we don't even know about. Ditch 'em. beats.each do |key| Resque.logger.info "Removing #{key} from heartbeats because the worker isn't talking to Resque." Resque.redis.del key end rescue Exception => e Resque.logger.error "#{e.message} #{e.backtrace}" end end |