Skip to content

Instantly share code, notes, and snippets.

@foloinfo
Forked from denmarkin/resque.rake
Last active August 29, 2015 13:56
Show Gist options
  • Save foloinfo/9131453 to your computer and use it in GitHub Desktop.
Save foloinfo/9131453 to your computer and use it in GitHub Desktop.
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :resque do
desc "Clear pending tasks"
task :clear => :environment do
queues = Resque.queues
queues.each do |queue_name|
puts "Clearing #{queue_name}..."
Resque.redis.del "queue:#{queue_name}"
end
puts "Clearing delayed..." # in case of scheduler - doesn't break if no scheduler module is installed
Resque.redis.keys("delayed:*").each do |key|
Resque.redis.del "#{key}"
end
Resque.redis.keys('timestamps:*').each do |key|
Resque.redis.del "#{key}"
end
Resque.redis.del "delayed_queue_schedule"
puts "Clearing stats..."
Resque.redis.set "stat:failed", 0
Resque.redis.set "stat:processed", 0
end
end
@foloinfo
Copy link
Author

clearing timestamps added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment