Skip to content

@kbaum /gist:892247
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
prune_workers_from_terminated_instance.rb
module Resque
def self.unregister_workers_for_host(host)
Resque.workers.select{|worker| worker.id.split(':').first==host}.each(&:unregister_worker)
end
end
Resque.unregister_workers_for_host("ip-10-250-192-51")
@mtalcott

Unregister resque workers for hosts that don't respond to pings:

worker_hosts = Resque.workers.map {|w| ip = w.id.split(":").first}.uniq
bad_hosts = worker_hosts.reject {|host| ip = host.gsub(/^ip-/, '').gsub('-', '.'); system "ping #{ip} -W 1 -c 1"}
Resque.workers.select {|w| bad_hosts.any? {|host| w.id.include?(host)}}.each(&:unregister_worker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.