Added '--all' to anvil-manage-daemons to enable optional daemons.

Signed-off-by: digimer <mkelly@alteeve.ca>
This commit is contained in:
digimer 2024-03-26 13:34:59 -04:00
parent 8028bf226f
commit 15a79d7bac
2 changed files with 31 additions and 6 deletions

View File

@ -21,12 +21,15 @@ When logging, record sensitive data, like passwords.
Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a significant amount of log data.
.SS "Commands:"
.TP
\fB\-\-enable\fR
All Anvil! daemons that are not enabled will be enabled.
\fB\-\-all\fR
There are performance monitoring daemons, like 'anvil-monitor-daemons' and 'anvil-monitor-performance' which log daemon states and performance data. When disabling, these are disabled. When enabling, these are NOT enabled. Using \fB\-\-all\fR will enable these daemons.
.TP
\fB\-\-disable\fR
All Anvil! daemons that are not disabled will be disabled.
.TP
\fB\-\-enable\fR
All Anvil! daemons that are not enabled will be enabled.
.TP
\fB\-\-log\-only\fR
if this is passed, it monitors the status of the daemons, but does not try to recover failed ones.
.TP

View File

@ -26,8 +26,9 @@ my $anvil = Anvil::Tools->new();
# Read switches
$anvil->Get->switches({list => [
"enable",
"all",
"disable",
"enable",
"log-only",
"monitor",
"now",
@ -40,10 +41,10 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure =
# Common daemons
$anvil->data->{daemons}{core}{'anvil-daemon'} = "anvil-daemon.service";
$anvil->data->{daemons}{core}{'anvil-monitor-daemons'} = "anvil-monitor-daemons.service";
$anvil->data->{daemons}{core}{'anvil-monitor-network'} = "anvil-monitor-network.service";
$anvil->data->{daemons}{core}{'anvil-monitor-performance'} = "anvil-monitor-performance.service";
$anvil->data->{daemons}{core}{'scancore'} = "scancore.service";
$anvil->data->{daemons}{core}{'anvil-monitor-network'} = "anvil-monitor-network.service";
$anvil->data->{daemons}{core}{'anvil-monitor-daemons'} = "anvil-monitor-daemons.service";
$anvil->data->{daemons}{core}{'anvil-monitor-performance'} = "anvil-monitor-performance.service";
# Striker dashboards.
$anvil->data->{daemons}{striker}{'striker-ui-api'} = "striker-ui-api.service";
@ -266,6 +267,17 @@ sub process_daemons
# Enable or disable?
if (($anvil->data->{switches}{enable}) && ($anvil->data->{daemon}{$daemon}{enabled}{return_code} == 1))
{
# Is this optional, and if so, did they use '--all'?
if (($daemon eq 'anvil-monitor-daemons') or ($daemon eq 'anvil-monitor-performance'))
{
if (not $anvil->data->{switches}{all})
{
# Skip this
print "The daemon: [".$daemon."] is not critical, and '--all' not used, not enabling it.\n";
next;
}
}
my $shell_call = $anvil->data->{path}{exe}{systemctl}." enable ".$daemon;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { shell_call => $shell_call }});
@ -292,6 +304,16 @@ sub process_daemons
# Start or stop?
if (($anvil->data->{switches}{start}) && ($anvil->data->{daemon}{$daemon}{active}{return_code} == 3))
{
if (($daemon eq 'anvil-monitor-daemons') or ($daemon eq 'anvil-monitor-performance'))
{
if (not $anvil->data->{switches}{all})
{
# Skip this
print "The daemon: [".$daemon."] is not critical, and '--all' not used, not starting it.\n";
next;
}
}
my $shell_call = $anvil->data->{path}{exe}{systemctl}." start ".$daemon;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { shell_call => $shell_call }});