Sha256: 269b6a5cc399fa726d324c3f9990f371112c65406141867583e9ffce9dbf0049
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
# require 'resque_admin/tasks' # will give you the resque tasks namespace :resque do task :setup desc "Start a ResqueAdmin worker" task :work => [ :preload, :setup ] do require 'resque_admin' begin worker = ResqueAdmin::Worker.new rescue ResqueAdmin::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 ResqueAdmin 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::VERSION::MAJOR > 3 ActiveSupport.run_load_hooks(:before_eager_load, Rails.application) Rails.application.config.eager_load_namespaces.each(&:eager_load!) elsif Rails::VERSION::MAJOR == 3 ActiveSupport.run_load_hooks(:before_eager_load, Rails.application) Rails.application.eager_load! elsif defined?(Rails::Initializer) $rails_rake_task = false Rails::Initializer.run :load_application_classes end end end namespace :failures do desc "Sort the 'failed' queue for the redis_multi_queue failure backend" task :sort do require 'resque_admin' require 'resque_admin/failure/redis' warn "Sorting #{ResqueAdmin::Failure.count} failures..." ResqueAdmin::Failure.each(0, ResqueAdmin::Failure.count) do |_, failure| data = ResqueAdmin.encode(failure) ResqueAdmin.redis.rpush(ResqueAdmin::Failure.failure_queue_name(failure['queue']), data) end warn "done!" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
resque_admin-1.0.5 | lib/resque_admin/tasks.rb |