Sha256: f2777af32160951b20b489ed7a14db8cf4d1c1d2ab201dfd3310d46fb60d148b

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

namespace :delayed do
  namespace :heartbeat do
    desc 'Cleans up workers that have not heartbeated recently.'
    task delete_timed_out_workers: :environment do
      results = Delayed::Heartbeat.delete_timed_out_workers
      print_results(results)
    end

    desc 'Cleans up workers running a different version.'
    task delete_workers_with_different_version: :environment do
      results = Delayed::Heartbeat.delete_workers_with_different_version
      print_results(results)
    end

    def print_results(results)
      puts "Deleted #{results.workers.size} and unlocked #{results.unlocked_jobs.size} orphaned jobs"
      puts results.to_s if verbose? && results.present?
    end

    def verbose?
      ENV['VERBOSE'].to_s.downcase == 'true'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
delayed_job_heartbeat_plugin-0.2.0 lib/delayed/heartbeat/tasks.rb
delayed_job_heartbeat_plugin-0.1.0 lib/delayed/heartbeat/tasks.rb