Class: Ductwork::Processes::WorkerHealthCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/ductwork/processes/worker_health_check.rb

Constant Summary collapse

KILL_BUDGET =
3
JOIN_TIMEOUT =
1

Instance Method Summary collapse

Constructor Details

#initialize(workers, role) ⇒ WorkerHealthCheck

Returns a new instance of WorkerHealthCheck.



9
10
11
12
# File 'lib/ductwork/processes/worker_health_check.rb', line 9

def initialize(workers, role)
  @workers = workers
  @role = role
end

Instance Method Details

#checkObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ductwork/processes/worker_health_check.rb', line 14

def check
  deadline = Time.current + KILL_BUDGET

  workers.each do |worker|
    if !worker.alive?
      restart_dead_worker(worker)
    elsif worker.stuck?
      restart_stuck_worker(worker, deadline)
    end
  end
end