Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (49 sloc) 1.464 kb
# require 'resque/tasks'
# will give you the resque tasks
namespace :resque do
task :setup
desc "Start a Resque worker"
task :work => [ :preload, :setup ] do
require 'resque'
begin
#worker = Resque::Worker.new(*queues)
supervisor = Resque::Supervisor.new
supervisor.spawn_workers
supervisor.watch_workers
#worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
#worker.very_verbose = ENV['VVERBOSE']
end
if ENV['BACKGROUND']
unless Process.respond_to?('daemon')
abort "env var BACKGROUND is set, which requires ruby >= 1.9"
end
Process.daemon(true)
end
#if ENV['PIDFILE']
# File.open(ENV['PIDFILE'], 'w') { |f| f << worker.pid }
#end
#worker.log "Starting worker #{worker}"
worker.work(ENV['INTERVAL'] || 5) # interval, will block
end
desc "Start multiple Resque workers. Should only be used in dev mode."
task :workers do
threads = []
ENV['COUNT'].to_i.times do
threads << Thread.new do
system "rake resque:work"
end
end
threads.each { |thread| thread.join }
end
# Preload app files if this is Rails
task :preload => :setup do
if defined?(Rails) && Rails.respond_to?(:application)
# Rails 3
Rails.application.eager_load!
elsif defined?(Rails::Initializer)
# Rails 2.3
$rails_rake_task = false
Rails::Initializer.run :load_application_classes
end
end
end
Jump to Line
Something went wrong with that request. Please try again.