Sha256: 01c33f0c258d3f4073a353e3ce7dfdd3c1d7f9bf707fe42887ac945a545a4c58

Contents?: true

Size: 877 Bytes

Versions: 9

Compression:

Stored size: 877 Bytes

Contents

# require 'resque/tasks'
# will give you the resque tasks

namespace :resque do
  task :setup

  desc "Start a Resque worker"
  task :work => :setup do
    require 'resque'

    worker = nil
    queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')

    begin
      worker = Resque::Worker.new(*queues)
      worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
      worker.very_verbose = ENV['VVERBOSE']
    rescue Resque::NoQueueError
      abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
    end

    puts "*** Starting worker #{worker}"

    worker.work(ENV['INTERVAL'] || 5) # interval, will block
  end

  desc "Start multiple Resque workers"
  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
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
grockit-resque-1.5.0 lib/resque/tasks.rb
resque-1.5.0 lib/resque/tasks.rb
resque-mongo-1.4.0 lib/resque/tasks.rb
resque-1.4.0 lib/resque/tasks.rb
resque-mongo-1.3.1 lib/resque/tasks.rb
resque-1.3.1 lib/resque/tasks.rb
resque-1.3.0 lib/resque/tasks.rb
resque-1.2.3 lib/resque/tasks.rb
resque-1.2.1 lib/resque/tasks.rb