Skip to content

Instantly share code, notes, and snippets.

@joshuacronemeyer
Last active October 5, 2016 06:04
Show Gist options
  • Save joshuacronemeyer/9efd1f3ae412359a414ee41ddd700086 to your computer and use it in GitHub Desktop.
Save joshuacronemeyer/9efd1f3ae412359a414ee41ddd700086 to your computer and use it in GitHub Desktop.
scheduler_migration.rb
#running resque jobs for all queues from a one-off console
worker = Resque::Worker.new("*")
worker.work
#getting all delayed jobs from old resque scheduler
all = Resque.delayed_queue_peek(0,2000).map{|ts| Resque.delayed_timestamp_peek(ts, 0, 2000).map{|it| it[:ts] = ts;it} }
#switch to new redis
Resque.redis = ENV['RESQUE_REDIS_URL']
#enquque all jobs
all.each do |it|
#except this didn't seem to work for me
Resque.enqueue_at_with_queue(it["queue"], it[:ts], it["class"], it["args"])
end
all.each{|it| Resque.enqueue_at_with_queue(it["queue"], it[:ts], it["class"], it["args"])}
#running jobs after you set some arbitrary Resque.redis value lets you run off jobs somewhere else
scheduler_cli = Resque::Scheduler::Cli.new
scheduler_cli.setup_env
scheduler_cli.run_forever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment