Class: ConfigOMat::Op::CheckServiceStatus

Inherits:
LifecycleVM::OpBase
  • Object
show all
Defined in:
lib/config_o_mat/flip_flopper/op/check_service_status.rb

Instance Method Summary collapse

Instance Method Details

#callObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/config_o_mat/flip_flopper/op/check_service_status.rb', line 26

def call
  if min_wait > 0
    do_sleep(min_wait)
  else
    do_sleep(1)
  end

  instance_name = "#{service}#{activating_instance}"

  if !activating_interface
    self.activating_interface = systemd_interface.service_interface(instance_name)
  end

  if !activating_interface
    logger&.error(:ipc_failure, name: instance_name)
    self.activation_status = :failed
    return
  end

  reported_status = activating_interface['ActiveState']

  logger&.info(:service_status, name: instance_name, status: reported_status)

  if reported_status == 'active'
    self.activation_status = :started
  elsif reported_status == 'activating'
    if max_wait > 0
      self.activation_status = :starting
    else
      self.activation_status = :timed_out
    end
  else
    self.activation_status = :failed
  end
end