Created
December 4, 2014 15:47
-
-
Save stevegraham/b60cc852c010c72760e7 to your computer and use it in GitHub Desktop.
Run ActiveJobs with Sneakers
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
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