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
|
# File 'lib/config_o_mat/flip_flopper/op/determine_running_instance.rb', line 27
def call
i1_name = "#{service}1"
i1_status = systemd_interface.service_status(i1_name)
logger&.info(:service_status, name: i1_name, status: i1_status)
i2_name = "#{service}2"
i2_status = systemd_interface.service_status(i2_name)
logger&.info(:service_status, name: i2_name, status: i2_status)
i1_running = RUNNING_STATES.include?(i1_status)
i2_running = RUNNING_STATES.include?(i2_status)
if i1_running && i2_running
error :service, 'both instances are currently running!'
elsif i1_running
self.activating_instance = 2
self.running_instance = 1
elsif i2_running
self.activating_instance = 1
self.running_instance = 2
else
self.activating_instance = 1
self.running_instance = 2
end
end
|