Created
December 3, 2013 15:34
-
-
Save ansonK/7771276 to your computer and use it in GitHub Desktop.
Quick and dirty way of transferring enqueued sidekiq jobs from a non-namespaced sidekiq environment to a namespaced one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
no_namespace_redis = Sidekiq::RedisConnection.create({ url: ENV['REDISCLOUD_URL'] }) | |
namespace_redis = Sidekiq::RedisConnection.create({ url: ENV['REDISCLOUD_URL'], namespace: "#{ENV['SIDEKIQ_NAMESPACE'] || Rails.env}" }) | |
Sidekiq.instance_variable_set "@redis", no_namespace_redis | |
Sidekiq::Stats.new.queues | |
queue_names = Sidekiq::Stats.new.queues.select {|k,v| v.to_i > 0 }.keys | |
puts "Queue Names: #{queue_names.inspect}" | |
queue_names.each do |queue_name| | |
Sidekiq::Queue.new(queue_name).each do |job| | |
puts "queue: #{job.queue}" | |
puts "klass: #{job.klass}" | |
puts "args: #{job.args}" | |
Sidekiq.instance_variable_set "@redis", namespace_redis | |
Sidekiq::Client.push 'queue' => job.queue.to_s, 'class' => job.klass.constantize, 'args' => job.args | |
end | |
Sidekiq.instance_variable_set "@redis", no_namespace_redis | |
end | |
nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment