From 0200b21ac9601adcf272cf89f60574d05e5434db Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 31 Oct 2019 13:41:05 +0100 Subject: [PATCH] Add support to keep PowerShell open while running as daemon --- lib/daemon/Start-IcingaPowerShellDaemon.psm1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 index 4fe858c..87bbc53 100644 --- a/lib/daemon/Start-IcingaPowerShellDaemon.psm1 +++ b/lib/daemon/Start-IcingaPowerShellDaemon.psm1 @@ -1,5 +1,9 @@ function Start-IcingaPowerShellDaemon() { + param( + [switch]$RunAsService + ); + $ScriptBlock = { param($IcingaDaemonData); @@ -32,4 +36,10 @@ function Start-IcingaPowerShellDaemon() $global:IcingaDaemonData.Add('Config', (Read-IcingaPowerShellConfig)); New-IcingaThreadInstance -Name "Icinga_PowerShell_Background_Daemon" -ThreadPool $IcingaDaemonData.IcingaThreadPool.BackgroundPool -ScriptBlock $ScriptBlock -Arguments @( $global:IcingaDaemonData ) -Start; + + if ($RunAsService) { + while ($TRUE) { + Start-Sleep -Seconds 100; + } + } }