lib/resque/worker.rb
# Looks for any workers which should be running on this server
# and, if they're not, removes them from Redis.
#
# This is a form of garbage collection. If a server is killed by a
# hard shutdown, power failure, or something else beyond our
# control, the Resque workers will not die gracefully and therefore
# will leave stale state information in Redis.
#
# By checking the current Redis state against the actual
# environment, we can determine if Redis is old and clean it up a bit.
Looks for any workers which should be running on this server
and, if they're not, removes them from Redis.

This is a form of garbage collection. If a server is killed by a
hard shutdown, power failure, or something else beyond our
control, the Resque workers will not die gracefully and therefore
will leave stale state information in Redis.

By checking the current Redis state against the actual
environment, we can determine if Redis is old and clean it up a bit.
Looks for any workers which should be running on this server and if they ' re not removes them from Redis . This is a form of garbage collection . If a server is killed by a hard shutdown power failure or something else beyond our control the Resque workers will not die gracefully and therefore will leave stale state information in Redis . By checking the current Redis state against the actual environment we can determine if Redis is old and clean it up a bit .
def prune_dead_workers
      all_workers = Worker.all
      known_workers = worker_pids unless all_workers.empty?
      all_workers.each do |worker|
        host, pid = worker.id.split(':')
        next unless host == hostname
        next if known_workers.include?(pid)
        log! "Pruning dead worker: #{worker}"
        worker.unregister_worker
      end
    end
def prune_dead_workers all_workers = Worker . all known_workers = worker_pids unless all_workers . empty? all_workers . each do | worker | host , pid = worker . id . split ( ':' ) next unless host == hostname next if known_workers . include? ( pid ) log! "Pruning dead worker: #{worker}" worker . unregister_worker end end
Looks for any workers which should be running on this server
and, if they're not, removes them from Redis.
Looks for any workers which should be running on this server and if they ' re not removes them from Redis .