icinga-powershell-framework/lib/core/thread/New-IcingaThreadPool.psm1

32 lines
907 B
PowerShell
Raw Normal View History

function New-IcingaThreadPool()
{
param(
[int]$MinInstances = 1,
[int]$MaxInstances = 5
);
2021-08-06 12:12:27 -04:00
$SessionConfiguration = $null;
$SessionFile = Get-IcingaJEASessionFile;
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext))) {
$SessionConfiguration = [System.Management.Automation.RunSpaces.InitialSessionState]::CreateDefault();
2021-08-06 12:12:27 -04:00
} else {
if ([string]::IsNullOrEmpty($SessionFile)) {
Write-IcingaEventMessage -EventId 1502 -Namespace 'Framework';
return $null;
}
$SessionConfiguration = [System.Management.Automation.Runspaces.InitialSessionState]::CreateFromSessionConfigurationFile($SessionFile);
}
$RunSpaces = [RunSpaceFactory]::CreateRunSpacePool(
$MinInstances,
$MaxInstances,
2021-08-06 12:12:27 -04:00
$SessionConfiguration,
$host
)
$RunSpaces.Open();
return $RunSpaces;
}