mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
26 lines
765 B
PowerShell
26 lines
765 B
PowerShell
|
|
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;
|
||
|
|
}
|
||
|
|
}
|