Resque :: How to clear old workers from Redis
In a Rails 3 application we’re using resque for background jobs. Because we’re running on heroku, with new deploys sometimes appears “phantom” resque workers in resque-web, this “phantom” workers are old workers that running on a previous EC2 instance that currently is terminated, so the phantom workers really don’t exist but the keys are still in Redis.
The way I clean this phantom workers is:
File: ./lib/resque_ext.rb
module ResqueExt
#
# ResqueExt.unregister_workers_for_host("ec210-250-192-51")
#
def self.unregister_workers_for_host(host)
Resque.workers.select{|worker| worker.id.split(':').first==host}.each(&:unregister_worker)
end
end
BTW the ./config/application.rb file includes the ./lib folder to be autoloadable:
config.autoload_paths += %W(#{config.root}/lib)
Based on this gist
19 Notes/ Hide
-
mystonyfieldex liked this
-
christinaert liked this
-
security980dek liked this
-
emileeyou89 liked this
-
gemfury liked this
-
edgar posted this