mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
27 lines
1 KiB
PowerShell
27 lines
1 KiB
PowerShell
function Start-IcingaPowerShellDaemon()
|
|
{
|
|
$ScriptBlock = {
|
|
param($IcingaDaemonData);
|
|
|
|
Use-Icinga -LibOnly -Daemon;
|
|
|
|
try {
|
|
# Todo: Add dynamic loading of enabled background tasks
|
|
Start-IcingaServiceCheckDaemon;
|
|
} catch {
|
|
# Todo: Add exception handling
|
|
}
|
|
|
|
while ($TRUE) {
|
|
Start-Sleep -Seconds 1;
|
|
}
|
|
};
|
|
|
|
$global:IcingaDaemonData.FrameworkRunningAsDaemon = $TRUE;
|
|
$global:IcingaDaemonData.Add('BackgroundDaemon', [hashtable]::Synchronized(@{}));
|
|
# Todo: Add config for active background tasks. Set it to 20 for the moment
|
|
$global:IcingaDaemonData.IcingaThreadPool.Add('BackgroundPool', (New-IcingaThreadPool -MaxInstances 20));
|
|
$global:IcingaDaemonData.Add('Config', (Read-IcingaPowerShellConfig));
|
|
|
|
New-IcingaThreadInstance -Name "Icinga_PowerShell_Background_Daemon" -ThreadPool $IcingaDaemonData.IcingaThreadPool.BackgroundPool -ScriptBlock $ScriptBlock -Arguments @( $global:IcingaDaemonData ) -Start;
|
|
}
|