icinga-powershell-framework/lib/daemon/Add-IcingaForWindowsDaemon.psm1

29 lines
860 B
PowerShell
Raw Normal View History

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) {
Start-Sleep -Seconds 1;
2022-03-18 15:58:56 -04:00
# Handle possible threads being frozen
Suspend-IcingaForWindowsFrozenThreads;
2021-08-06 12:12:27 -04:00
}
}