mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Add support to keep PowerShell open while running as daemon
This commit is contained in:
parent
51042d6c0e
commit
0200b21ac9
1 changed files with 10 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
function Start-IcingaPowerShellDaemon()
|
function Start-IcingaPowerShellDaemon()
|
||||||
{
|
{
|
||||||
|
param(
|
||||||
|
[switch]$RunAsService
|
||||||
|
);
|
||||||
|
|
||||||
$ScriptBlock = {
|
$ScriptBlock = {
|
||||||
param($IcingaDaemonData);
|
param($IcingaDaemonData);
|
||||||
|
|
||||||
|
|
@ -32,4 +36,10 @@ function Start-IcingaPowerShellDaemon()
|
||||||
$global:IcingaDaemonData.Add('Config', (Read-IcingaPowerShellConfig));
|
$global:IcingaDaemonData.Add('Config', (Read-IcingaPowerShellConfig));
|
||||||
|
|
||||||
New-IcingaThreadInstance -Name "Icinga_PowerShell_Background_Daemon" -ThreadPool $IcingaDaemonData.IcingaThreadPool.BackgroundPool -ScriptBlock $ScriptBlock -Arguments @( $global:IcingaDaemonData ) -Start;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue