fix(cgi-bin): stop servers when shutting down the whole anvil

main
Tsu-ba-me 4 years ago
parent 9a483b5d55
commit 5c7d9d9e82
  1. 5
      cgi-bin/set_power

@ -59,7 +59,7 @@ sub set_anvil_power
foreach (@host_uuids) foreach (@host_uuids)
{ {
set_host_power({ host_uuid => $_, on => $on }); set_host_power({ host_uuid => $_, on => $on, stop_servers => 1 });
} }
} }
@ -69,6 +69,7 @@ sub set_host_power
my $parameters = shift; my $parameters = shift;
my $host_uuid = $parameters->{host_uuid}; my $host_uuid = $parameters->{host_uuid};
my $on = $parameters->{on}; my $on = $parameters->{on};
my $stop_servers = exists $parameters->{stop_servers} ? "--stop-servers" : "";
# Check the host's status before trying to power it up/down. # Check the host's status before trying to power it up/down.
my $is_host_on = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_status} eq "online" ? 1 : 0; my $is_host_on = $anvil->data->{hosts}{host_uuid}{$host_uuid}{host_status} eq "online" ? 1 : 0;
@ -90,7 +91,7 @@ sub set_host_power
if ($is_host_on && not $on) if ($is_host_on && not $on)
{ {
$anvil->Database->insert_or_update_jobs({ $anvil->Database->insert_or_update_jobs({
job_command => $anvil->data->{path}{exe}{'anvil-safe-stop'}." --power-off", job_command => $anvil->data->{path}{exe}{'anvil-safe-stop'}." --power-off ".$stop_servers,
job_host_uuid => $host_uuid, job_host_uuid => $host_uuid,
job_description => "job_0333", job_description => "job_0333",
job_name => "cgi-bin::set_power::off", job_name => "cgi-bin::set_power::off",

Loading…
Cancel
Save