Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created December 4, 2014 15:47
Show Gist options
  • Save stevegraham/b60cc852c010c72760e7 to your computer and use it in GitHub Desktop.
Save stevegraham/b60cc852c010c72760e7 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