Class: Resqutils::StaleWorkersKiller

Inherits:
Object
  • Object
show all
Defined in:
lib/resqutils/stale_workers_killer.rb

Overview

Vends stale workers that have been running “too long”

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ StaleWorkersKiller

Returns a new instance of StaleWorkersKiller


9
10
11
# File 'lib/resqutils/stale_workers_killer.rb', line 9

def initialize(options={})
  @stale_workers = options.fetch(:stale_workers, Resqutils::StaleWorkers.new)
end

Class Method Details

.performObject


5
6
7
# File 'lib/resqutils/stale_workers_killer.rb', line 5

def self.perform
  self.new.kill_stale_workers
end

Instance Method Details

#kill_stale_workersObject


12
13
14
15
16
# File 'lib/resqutils/stale_workers_killer.rb', line 12

def kill_stale_workers
  @stale_workers.each do |worker|
    Resque.enqueue(Resqutils::WorkerKillerJob,worker.id)
  end
end