lib/resque/tasks.rb in resque-1.26.pre.0 vs lib/resque/tasks.rb in resque-1.26.0

- old
+ new

@@ -1,50 +1,32 @@ # 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' - queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',') - begin - worker = Resque::Worker.new(*queues) - if ENV['LOGGING'] || ENV['VERBOSE'] - worker.verbose = ENV['LOGGING'] || ENV['VERBOSE'] - end - if ENV['VVERBOSE'] - worker.very_verbose = ENV['VVERBOSE'] - end - worker.term_timeout = ENV['RESQUE_TERM_TIMEOUT'] || 4.0 - worker.term_child = ENV['TERM_CHILD'] - worker.run_at_exit_hooks = ENV['RUN_AT_EXIT_HOOKS'] + worker = Resque::Worker.new rescue Resque::NoQueueError abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work" end - if ENV['BACKGROUND'] - unless Process.respond_to?('daemon') - abort "env var BACKGROUND is set, which requires ruby >= 1.9" - end - Process.daemon(true, true) - end - - if ENV['PIDFILE'] - File.open(ENV['PIDFILE'], 'w') { |f| f << worker.pid } - end - - worker.log "Starting worker #{worker}" - + worker.log "Starting worker #{self}" 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 = [] + + if ENV['COUNT'].to_i < 1 + abort "set COUNT env var, e.g. $ COUNT=2 rake resque:workers" + end ENV['COUNT'].to_i.times do threads << Thread.new do system "rake resque:work" end