Sha256: a98bf247ccdb209aacdbfa2f8b7bdfc894c339197fab90f2d028251ec1402a54
Contents?: true
Size: 1.61 KB
Versions: 4
Compression:
Stored size: 1.61 KB
Contents
# 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 rescue Resque::NoQueueError abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work" end worker.prepare 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 end threads.each { |thread| thread.join } end # Preload app files if this is Rails task :preload => :setup do if defined?(Rails) if Rails.application.config.eager_load ActiveSupport.run_load_hooks(:before_eager_load, Rails.application) Rails.application.config.eager_load_namespaces.each(&:eager_load!) end end end namespace :failures do desc "Sort the 'failed' queue for the redis_multi_queue failure backend" task :sort do require 'resque' require 'resque/failure/redis' warn "Sorting #{Resque::Failure.count} failures..." Resque::Failure.each(0, Resque::Failure.count) do |_, failure| data = Resque.encode(failure) Resque.redis.rpush(Resque::Failure.failure_queue_name(failure['queue']), data) end warn "done!" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
resque-2.2.1 | lib/resque/tasks.rb |
resque-2.2.0 | lib/resque/tasks.rb |
resque-2.1.0 | lib/resque/tasks.rb |
resque-2.0.0 | lib/resque/tasks.rb |