Sha256: 5b3c1644d5ec37edca74927233129ea8bbb86143411dd104efd2d9e17813abe6
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
namespace :jobs do desc "Clear the delayed_job queue." task :clear => :environment do Delayed::Job.delete_all end desc "Start a delayed_job worker." task :work => :environment_options do Delayed::Worker.new(@worker_options).start end desc "Start a delayed_job worker and exit when all available jobs are complete." task :workoff => :environment_options do Delayed::Worker.new(@worker_options.merge({:exit_on_complete => true})).start end task :environment_options => :environment do @worker_options = { :min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY'], :queues => (ENV['QUEUES'] || ENV['QUEUE'] || '').split(','), :quiet => false } end desc "Exit with error status if any jobs older than max_age seconds haven't been attempted yet." task :check, [:max_age] => :environment do |_, args| args.with_defaults(:max_age => 300) unprocessed_jobs = Delayed::Job.where('attempts = 0 AND created_at < ?', Time.now - args[:max_age].to_i).count if unprocessed_jobs > 0 fail "#{unprocessed_jobs} jobs older than #{args[:max_age]} seconds have not been processed yet" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
delayed_job-4.0.2 | lib/delayed/tasks.rb |
delayed_job-4.0.1 | lib/delayed/tasks.rb |
delayed_job-4.0.0 | lib/delayed/tasks.rb |
delayed_job-4.0.0.beta2 | lib/delayed/tasks.rb |