@ -72,7 +72,7 @@ $anvil->Log->secure({set => 1});
# Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks
# is to setup the database server.
$anvil->Database->connect({debug => 3, check_if_configured => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , secure => 0, key => "log_0132"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , secure => 0, key => "log_0132"});
# If I have no databases, sleep for a second and then exit (systemd will restart us).
if (not $anvil->data->{sys}{database}{connections})
@ -117,7 +117,7 @@ $anvil->Storage->record_md5sums;
# Disconnect. We'll reconnect inside the loop
$anvil->Database->disconnect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , 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;
@ -131,7 +131,7 @@ $anvil->data->{timing}{minute_checks} = 60;
$anvil->data->{timing}{repo_update_interval} = 86400;
$anvil->data->{timing}{next_minute_check} = $now_time - 1;
$anvil->data->{timing}{next_repo_check} = $now_time; # We want to run on daemon startup
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
"s1:timing::minute_checks" => $anvil->data->{timing}{minute_checks},
"s2:timing::repo_update_interval" => $anvil->data->{timing}{repo_update_interval},
"s3:now_time" => $now_time,
@ -153,7 +153,7 @@ while(1)
$anvil->Get->switches; # Re-read to let switches override again.
$anvil->Words->read();
$anvil->Database->connect({check_if_configured => $check_if_database_is_configured});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , secure => 0, key => "log_0132"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , secure => 0, key => "log_0132"});
# Mark that we don't want to check the database now.
$check_if_database_is_configured = 0;
@ -181,7 +181,7 @@ while(1)
# Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect();
sleep(1 );
sleep(2 );
}
$anvil->nice_exit({code => 0});
@ -229,7 +229,7 @@ sub handle_periodic_tasks
# Update the next check time.
$anvil->data->{timing}{next_minute_check} = $now_time + $anvil->data->{timing}{minute_checks};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"s1:timing::minute_checks" => $anvil->data->{timing}{minute_checks},
"s2:timing::next_minute_check" => $anvil->data->{timing}{next_minute_check},
}});
@ -286,11 +286,11 @@ sub handle_periodic_tasks
job_description => "job_0017",
job_progress => 0,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1 , list => { job_uuid => $job_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { job_uuid => $job_uuid }});
# Update the next check time.
$anvil->data->{timing}{next_repo_check} = $now_time + $anvil->data->{timing}{repo_update_interval};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"s1:timing::repo_update_interval" => $anvil->data->{timing}{repo_update_interval},
"s2:timing::next_repo_check" => $anvil->data->{timing}{next_repo_check},
}});
@ -468,7 +468,7 @@ sub check_ssh_keys
{
$update_known_hosts = 1;
$known_hosts_new_lines .= $test_line."\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
's1:update_known_hosts' => $update_known_hosts,
's2:known_hosts_new_lines' => $known_hosts_new_lines,
}});
@ -591,7 +591,7 @@ sub check_ssh_keys
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { update_authorized_keys => $update_authorized_keys }});
if ($update_authorized_keys)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0273", variables => { user => $user, file => $authorized_keys_file }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0273", variables => { user => $user, file => $authorized_keys_file }});
if (-e $authorized_keys_file)
{
my $backup_file = $anvil->Storage->backup({
@ -599,10 +599,10 @@ sub check_ssh_keys
fatal => 1,
file => $authorized_keys_file,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { backup_file => $backup_file }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { backup_file => $backup_file }});
if (-e $backup_file)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0154", variables => { source_file => $authorized_keys_file, target_file => $backup_file }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0154", variables => { source_file => $authorized_keys_file, target_file => $backup_file }});
}
else
{
@ -618,7 +618,7 @@ sub check_ssh_keys
group => $user,
mode => "0644",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { failed => $failed }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { failed => $failed }});
}
}
@ -758,15 +758,15 @@ sub check_install_target
my $status = "unavailable";
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'striker-manage-install-target'}." --status --check --no-refresh"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { output => $output }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { output => $output }});
foreach my $line (split/\n/, $output)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { line => $line }});
if ($line =~ /status=(\d)/)
{
my $digit = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { digit => $digit }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { digit => $digit }});
if ($digit == 0)
{
@ -776,7 +776,7 @@ sub check_install_target
{
$status = "enabled";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { status => $status }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { status => $status }});
last;
}
}
@ -822,10 +822,17 @@ sub run_once
sub check_firewall
{
my ($anvil) = @_;
# Don't call this if we're not configured yet.
my $configured = $anvil->System->check_if_configured({debug => 2});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { configured => $configured }});
# Check the firewall needs to be updated.
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'anvil-manage-firewall'}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output => $output }});
if ($configured)
{
my $output = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{'anvil-manage-firewall'}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output => $output }});
}
return(0);
}
@ -942,7 +949,7 @@ sub keep_running
{
# If it's not a handle, delete it.
my $running = $anvil->data->{jobs}{handles}{$job_uuid}->poll();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid},
running => $running,
}});
@ -966,7 +973,7 @@ sub keep_running
# Update hardware state files if the system isn't configured. Running it always is too intensive.
my $configured = $anvil->System->check_if_configured;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { configured => $configured }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { configured => $configured }});
if (not $configured)
{
update_state_file($anvil);
@ -1055,7 +1062,7 @@ sub run_jobs
if ((not exists $anvil->data->{lost_job_count}{$job_uuid}) or (not defined $anvil->data->{lost_job_count}{$job_uuid}))
{
$anvil->data->{lost_job_count}{$job_uuid} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
}
if ($anvil->data->{lost_job_count}{$job_uuid} > 5)
{
@ -1069,7 +1076,7 @@ sub run_jobs
# Clear some variables.
$job_progress = 0;
$job_status = "message_0056";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
job_progress => $job_progress,
job_status => $job_status,
}});
@ -1077,12 +1084,12 @@ sub run_jobs
# Clear the job.
$anvil->Job->clear({debug => 3, job_uuid => $job_uuid});
$anvil->data->{lost_job_count}{$job_uuid} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
}
else
{
$anvil->data->{lost_job_count}{$job_uuid}++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "lost_job_count::${job_uuid}" => $anvil->data->{lost_job_count}{$job_uuid} }});
}
}
@ -1147,7 +1154,7 @@ sub run_jobs
my $command = $job_command." --job-uuid ".$job_uuid;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0210", variables => { command => $command }});
$anvil->data->{jobs}{handles}{$job_uuid} = $anvil->System->call({
debug => 2 ,
debug => 3 ,
background => 1,
stdout_file => "/tmp/anvil.job.".$job_uuid.".stdout",
stderr_file => "/tmp/anvil.job.".$job_uuid.".stderr",
@ -1155,11 +1162,11 @@ sub run_jobs
source => $THIS_FILE,
line => __LINE__,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid} }});
# Log the PID (the job should update the database).
my $pid = $anvil->data->{jobs}{handles}{$job_uuid}->pid();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { pid => $pid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { pid => $pid }});
}
}