Sha256: 0cfae299958f174881838ef231c162b5276be04013dd40b2ce7957d45e95e6ab

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

# frozen_string_literal: true

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 if verbose? && results.present?
    end

    def verbose?
      ENV['VERBOSE'].to_s.casecmp('true').zero?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
delayed_job_heartbeat_plugin-0.6.0 lib/delayed/heartbeat/tasks.rb