2021-08-06 12:12:27 -04:00
|
|
|
function Add-IcingaForWindowsDaemon()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$EnabledDaemons = Get-IcingaBackgroundDaemons;
|
|
|
|
|
|
|
|
|
|
foreach ($daemon in $EnabledDaemons.Keys) {
|
|
|
|
|
Write-IcingaDebugMessage -Message 'Trying to enable background daemon' -Objects $daemon;
|
|
|
|
|
if (-Not (Test-IcingaFunction $daemon)) {
|
|
|
|
|
Write-IcingaEventMessage -EventId 1400 -Namespace 'Framework' $daemon;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$daemonArgs = $EnabledDaemons[$daemon];
|
|
|
|
|
Write-IcingaDebugMessage -Message 'Starting background daemon' -Objects $daemon, $daemonArgs;
|
|
|
|
|
|
|
|
|
|
& $daemon @daemonArgs;
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
# Todo: Add exception handling
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while ($TRUE) {
|
2022-03-17 04:31:32 -04:00
|
|
|
Start-Sleep -Seconds 10;
|
2022-03-18 15:58:56 -04:00
|
|
|
|
|
|
|
|
# Handle possible threads being frozen
|
|
|
|
|
Suspend-IcingaForWindowsFrozenThreads;
|
2022-03-17 04:31:32 -04:00
|
|
|
|
|
|
|
|
# Force Icinga for Windows Garbage Collection
|
|
|
|
|
Optimize-IcingaForWindowsMemory -ClearErrorStack -SmartGC;
|
2021-08-06 12:12:27 -04:00
|
|
|
}
|
|
|
|
|
}
|