Skip to content

Instantly share code, notes, and snippets.

@leshill
Created May 16, 2011 17:58
Show Gist options
  • Save leshill/974966 to your computer and use it in GitHub Desktop.
Save leshill/974966 to your computer and use it in GitHub Desktop.
Work in progress...
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_filter :scheduler_redirect if ENV['SCHEDULER_REDIRECT']
# ...
private
def scheduler_redirect
redirect_to ENV['SCHEDULER_REDIRECT']
end
end
# lib/resque.task
require 'resque/tasks'
require 'resque_scheduler/tasks'
module ResqueWorker
extend self
def scheduler_or_worker?
ENV['SCHEDULER_REDIRECT'] ? 'scheduler' : 'work'
end
end
task "resque:setup" => :environment
task "resque:scheduler_setup" => :environment # load the env so we know about the job classes
desc "Run Resque workers on Heroku"
task "jobs:work" => ["resque:setup", "resque:scheduler_setup"] do
ENV['QUEUE'] = '*'
Rake::Task["resque:#{ResqueWorker.scheduler_or_worker?}"].invoke
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment