Skip to content

Instantly share code, notes, and snippets.

@obskein
Forked from stevegraham/active_jerbz.rake
Created February 28, 2016 06:14
Show Gist options
  • Save obskein/f8ced55857d3aafe1d52 to your computer and use it in GitHub Desktop.
Save obskein/f8ced55857d3aafe1d52 to your computer and use it in GitHub Desktop.
Run ActiveJobs with Sneakers
require 'sneakers/runner'
task :environment
namespace :sneakers do
desc "Start processing jobs with all workers"
task :work => :environment do
silence_warnings do
Rails.application.eager_load! unless Rails.application.config.eager_load
end
workers = ActiveJob::Base.subclasses.map do |klass|
klass.const_set("Wrapper", Class.new(ActiveJob::QueueAdapters::SneakersAdapter::JobWrapper) do
from_queue klass.queue_name
end)
end
Sneakers::Runner.new(workers).run
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment