* Created System->check_if_configured and then used that to only have anvil-daemon call update_state_file() when the system is unconfigured (to reduce the laod) when it's usually not needed).

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 94d8a9c495
commit 39c94009e6
  1. 30
      Anvil/Tools/System.pm
  2. 23
      cgi-bin/striker
  3. 9
      tools/anvil-daemon

@ -18,6 +18,7 @@ my $THIS_FILE = "System.pm";
# call
# change_shell_user_password
# check_daemon
# check_if_configured
# check_memory
# determine_host_type
# enable_daemon
@ -460,6 +461,35 @@ sub check_daemon
return($return);
}
=head2 check_if_configured
This returns C<< 1 >> is the system has finished initial configuration, and C<< 0 >> if not.
This method takes no parameters.
=cut
sub check_if_configured
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my ($configured, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
variable_name => "system::configured",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
configured => $configured,
variable_uuid => $variable_uuid,
modified_date => $modified_date,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { configured => $configured }});
return($configured);
}
=head2 check_memory
# Not yet written...

@ -62,7 +62,7 @@ if (not $anvil->data->{sys}{database}{connections})
# If any jobs are pending/running, show the "unavailable" option.
my $available = check_availability($anvil);
my $configured = $available ? check_if_configured($anvil) : 0;
my $configured = $available ? $anvil->System->check_if_configured : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
available => $available,
configured => $configured,
@ -807,27 +807,6 @@ sub configure_striker
return(0);
}
# This checks to see if the local machine has been configured after initial install. If not, it will present
# the configuration menu.
sub check_if_configured
{
my ($anvil) = @_;
my ($configured, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
variable_name => "system::configured",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
configured => $configured,
variable_uuid => $variable_uuid,
modified_date => $modified_date,
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }});
return($configured);
}
# This checks to see if anything is running that requires Striker being unavailable. If not, this returns
# '1'. If there is a job pending/running, it returns '0'
sub check_availability

@ -133,7 +133,7 @@ while(1)
# Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect();
sleep(0.5);
sleep(1);
}
$anvil->nice_exit({code => 0});
@ -301,8 +301,13 @@ sub keep_running
}
}
# Update hardware state files.
# 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 }});
if (not $configured)
{
update_state_file($anvil);
}
# Run any pending jobs by calling 'anvil-jobs' with the 'job_uuid' as a background process.
run_jobs($anvil);

Loading…
Cancel
Save