* Udated anvil-daemon to not use Time::HiRes for now, and added a timer so that the md5sum of files used by the daemon are checked only once per minute. This significantly reduced the load caused by the daemon running.

* Bumped the RPM spec file to 15, though haven't actually rolled the new RPM yet. Also added 'htop' as an anvil-core dependencies.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 39c94009e6
commit 4bf048054b
  1. 7
      rpm/SPECS/anvil.spec
  2. 1
      share/words.xml
  3. 27
      tools/anvil-configure-striker
  4. 40
      tools/anvil-daemon

@ -3,7 +3,7 @@
%define anvilgroup admin %define anvilgroup admin
Name: anvil Name: anvil
Version: 3.0 Version: 3.0
Release: 15%{?dist} Release: 16%{?dist}
Summary: Alteeve Anvil! complete package. Summary: Alteeve Anvil! complete package.
License: GPLv2+ License: GPLv2+
@ -30,6 +30,7 @@ Requires: fence-agents-all
Requires: fence-agents-virsh Requires: fence-agents-virsh
Requires: firewalld Requires: firewalld
Requires: gpm Requires: gpm
Requires: htop
Requires: mlocate Requires: mlocate
Requires: perl-Data-Dumper Requires: perl-Data-Dumper
Requires: perl-DBD-Pg Requires: perl-DBD-Pg
@ -312,6 +313,10 @@ echo "WARNING: Setting SELinux to 'permissive' during development."
sed -i.anvil 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config sed -i.anvil 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
setenforce 0 setenforce 0
sed -i "1s/^.*$/%{version}-%{release}/" /%{_sysconfdir}/anvil/anvil.version sed -i "1s/^.*$/%{version}-%{release}/" /%{_sysconfdir}/anvil/anvil.version
# Enable and start the anvil-daemon
systemctl enable anvil-daemon.service
systemctl start anvil-daemon.service
%post striker %post striker
### NOTE: PostgreSQL is initialized and enabled by anvil-prep-database later. ### NOTE: PostgreSQL is initialized and enabled by anvil-prep-database later.

@ -102,6 +102,7 @@ The '-y' option prevents a confirmation prompt.
<key name="message_0062">Powering off the local system now.</key> <key name="message_0062">Powering off the local system now.</key>
<key name="message_0063">Rebooting the local system now.</key> <key name="message_0063">Rebooting the local system now.</key>
<key name="message_0064">The Anvil! has restarted at: [#!variable!date_and_time!#] after powering back on.</key> <key name="message_0064">The Anvil! has restarted at: [#!variable!date_and_time!#] after powering back on.</key>
<key name="message_0065">You will now be logged out and this machine will now be rebooted so that the new configuration can take effect.</key>
<!-- Log entries --> <!-- Log entries -->
<key name="log_0001">Starting: [#!variable!program!#].</key> <key name="log_0001">Starting: [#!variable!program!#].</key>

@ -63,14 +63,6 @@ pickup_job_details($anvil);
reconfigure_network($anvil); reconfigure_network($anvil);
update_passwords($anvil);
$anvil->Job->update_progress({
debug => 3,
progress => 100,
job_uuid => $anvil->data->{job}{uuid},
});
# Record that we've configured this machine. # Record that we've configured this machine.
$anvil->Database->insert_or_update_variables({ $anvil->Database->insert_or_update_variables({
variable_name => "system::configured", variable_name => "system::configured",
@ -81,10 +73,16 @@ $anvil->Database->insert_or_update_variables({
variable_source_uuid => $anvil->Get->host_uuid, variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts", variable_source_table => "hosts",
}); });
# Clear maintenance mode.
$anvil->System->maintenance_mode({set => 0});
# Clear maintenance mode update_passwords($anvil);
$anvil->Job->update_progress({
debug => 3,
progress => 100,
message => $anvil->data->{switches}{'no-reboot'} ? "message_0065" : "",
job_uuid => $anvil->data->{job}{uuid},
});
# Clear maintenance mode.
$anvil->System->maintenance_mode({set => 0}); $anvil->System->maintenance_mode({set => 0});
### TODO: This is only until we can get the damn networking stable on reconfigure. ### TODO: This is only until we can get the damn networking stable on reconfigure.
@ -92,8 +90,11 @@ $anvil->System->maintenance_mode({set => 0});
$anvil->System->reboot_needed({set => 1}); $anvil->System->reboot_needed({set => 1});
if (not $anvil->data->{switches}{'no-reboot'}) if (not $anvil->data->{switches}{'no-reboot'})
{ {
# Reboot. # Reboot, after waiting a few seconds to let the user's browser pick up the last messages in
$anvil->System->call({shell_call => $anvil->data->{path}{exe}{'anvil-manager-power'}." --reboot -y"}); # jobs.json. We'll also log the user out, in case we were re-configuring.
sleep 5;
$anvil->Account->logout;
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{'anvil-manage-power'}." --reboot -y"});
} }
$anvil->nice_exit({code => 0}); $anvil->nice_exit({code => 0});

@ -22,7 +22,7 @@ use strict;
use warnings; use warnings;
use Anvil::Tools; use Anvil::Tools;
use Proc::Simple; use Proc::Simple;
use Time::HiRes qw ( time sleep ); #use Time::HiRes qw ( time sleep );
use JSON; use JSON;
use HTML::Strip; use HTML::Strip;
use HTML::FromText; use HTML::FromText;
@ -43,7 +43,7 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure =
# Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks # 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. # is to setup the database server.
$anvil->Database->connect(); $anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
# If I have no databases, sleep for a second and then exit (systemd will restart us). # If I have no databases, sleep for a second and then exit (systemd will restart us).
if (not $anvil->data->{sys}{database}{connections}) if (not $anvil->data->{sys}{database}{connections})
@ -93,6 +93,16 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure =
# This will prevent restarting while jobs are running. # This will prevent restarting while jobs are running.
$anvil->data->{sys}{jobs_running} = 0; $anvil->data->{sys}{jobs_running} = 0;
# Once a minute, we'll check the md5sums and see if we should restart. We don't check every loop as it places a
my $md5_interval = 60;
my $now_time = time;
my $next_check = $now_time + $md5_interval;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:md5_interval" => $md5_interval,
"s2:now_time" => $now_time,
"s3:next_check" => $next_check,
}});
# These are the things we always want running. # These are the things we always want running.
while(1) while(1)
{ {
@ -103,7 +113,7 @@ while(1)
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# Loop and sleep for 2s. # Run the normal tasks
keep_running($anvil); keep_running($anvil);
} }
else else
@ -118,10 +128,26 @@ while(1)
} }
# Has the file on disk changed? # Has the file on disk changed?
if ((not $anvil->data->{sys}{jobs_running}) && ($anvil->Storage->check_md5sums)) $now_time = time;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:now_time" => $now_time,
"s2:next_check" => $next_check,
}});
if ($now_time >= $next_check)
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "warn", key => "message_0014"}); # Even if it is time to check, don't if a job is running.
$anvil->nice_exit({code => 1}); 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->nice_exit({code => 1});
}
# Update the next check time.
$next_check = $now_time + $md5_interval;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:md5_interval" => $md5_interval,
"s2:next_check" => $next_check,
}});
} }
# Exit if 'run-once' selected. # Exit if 'run-once' selected.
@ -279,7 +305,7 @@ sub keep_running
{ {
# If it's not a handle, delete it. # If it's not a handle, delete it.
my $running = $anvil->data->{jobs}{handles}{$job_uuid}->poll(); my $running = $anvil->data->{jobs}{handles}{$job_uuid}->poll();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid}, "jobs::handles::${job_uuid}" => $anvil->data->{jobs}{handles}{$job_uuid},
running => $running, running => $running,
}}); }});

Loading…
Cancel
Save