Class: Ductwork::Processes::HealthCheck

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid: nil, verbose: false) ⇒ HealthCheck

Returns a new instance of HealthCheck.



10
11
12
13
14
# File 'lib/ductwork/processes/health_check.rb', line 10

def initialize(pid: nil, verbose: false)
  @pid = pid
  @machine_identifier = Ductwork::MachineIdentifier.fetch
  @verbose = verbose
end

Class Method Details

.runObject



6
7
8
# File 'lib/ductwork/processes/health_check.rb', line 6

def self.run(**)
  new(**).run
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ductwork/processes/health_check.rb', line 16

def run
  exit_code = supervisor_processes.reduce(0) do |acc, process|
    if process.healthy?
      puts_healthy(process)
      acc
    else
      puts_unhealthy(process)
      acc + 1
    end
  end

  if pid.present? && supervisor_processes.none?
    puts_dead
    exit_code = 1
  end

  exit(exit_code)
end