* Fixed a bug where long-finished jobs where being displayed in the Striker maintenance mode display.

* Made it so that anvil-daemon won't restart when on-disk version has changed while jobs are still running.
* Made it so that anvil-update-system reloads systemctl after the update finishes to pickup changes in updated system daemons.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 12073ffa08
commit 6210524780
  1. 16
      cgi-bin/striker
  2. 19
      tools/anvil-daemon
  3. 4
      tools/anvil-update-system

@ -825,6 +825,20 @@ sub check_availability
job_title => $job_title, job_title => $job_title,
}}); }});
# Skip jobs that finished more than five minutes ago.
my $job_finished = time - $job_updated;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:time' => time,
's2:job_updated' => $job_updated,
's3:job_finished' => $job_finished,
}});
if (($job_progress eq "100") && ($job_finished > 600))
{
# Skip it
next;
}
# Convert the double-banged strings into a proper message. # Convert the double-banged strings into a proper message.
my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : ""; my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : ""; my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
@ -855,7 +869,7 @@ sub check_availability
description => $anvil->Words->string({key => "striker_0090", variables => { }}), description => $anvil->Words->string({key => "striker_0090", variables => { }}),
job_list => $jobs_list job_list => $jobs_list
}}); }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'say::maintenance' => $anvil->data->{say}{maintenance} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'say::maintenance' => $anvil->data->{say}{maintenance} }});
} }
# TODO: Phase this out # TODO: Phase this out

@ -73,12 +73,15 @@ $anvil->Storage->record_md5sums;
$anvil->Database->disconnect(); $anvil->Database->disconnect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0203"});
# This will prevent restarting while jobs are running.
$anvil->data->{sys}{jobs_running} = 0;
# These are the things we always want running. # These are the things we always want running.
while(1) while(1)
{ {
# Connect to the database(s) # Connect to the database(s)
$anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"}); $anvil->Storage->read_config({file => "/etc/anvil/anvil.conf"});
$anvil->Database->connect(); $anvil->Database->connect({debug => 2});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
@ -98,7 +101,7 @@ while(1)
} }
# Has the file on disk changed? # Has the file on disk changed?
if ($anvil->Storage->check_md5sums) if ((not $anvil->data->{sys}{jobs_running}) && ($anvil->Storage->check_md5sums))
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "warn", key => "message_0014"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "warn", key => "message_0014"});
$anvil->nice_exit({code => 1}); $anvil->nice_exit({code => 1});
@ -112,7 +115,7 @@ while(1)
} }
# Disconnect from the database(s) and sleep now. # Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect(); $anvil->Database->disconnect({debug => 2});
sleep 2; sleep 2;
} }
@ -243,6 +246,10 @@ sub run_jobs
{ {
my ($anvil) = @_; my ($anvil) = @_;
# This will be set to 1 if any jobs are not complete, preventing a restart of the daemon if it's
# changed on disk.
$anvil->data->{sys}{jobs_running} = 0;
# We'll also update the jobs.json file. # We'll also update the jobs.json file.
my $jobs_file = "{\"jobs\":[\n"; my $jobs_file = "{\"jobs\":[\n";
@ -284,6 +291,12 @@ sub run_jobs
updated_seconds_ago => $updated_seconds_ago, updated_seconds_ago => $updated_seconds_ago,
}}); }});
if ($job_progress ne "100")
{
$anvil->data->{sys}{jobs_running} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "sys::jobs_running" => $anvil->data->{sys}{jobs_running} }});
}
# See if the job was picked up by a now-dead instance. # See if the job was picked up by a now-dead instance.
if ($job_picked_up_by) if ($job_picked_up_by)
{ {

@ -382,6 +382,10 @@ sub run_os_update
} }
close $file_handle; close $file_handle;
# Reload daemons to pick up any changed systemctl daemons.
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." daemon-reload", source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
# Did it work? # Did it work?
if (not $success) if (not $success)
{ {

Loading…
Cancel
Save