I have an .exe for which I create multiple services and attach them to an Active Directory User Account for that service, I can create almost as many as I want. For most installations, it is usually 10. Each process is given a unique pair of ports to use, and they all start up, and operate fine.
The deployment team would like me to explore installing as Local System. They tried it and ran into issues, and so I have been playing with it and my observation is that after the fourth service is installed, then any new service install after that is unable to run/start. The process never appears to even get to application code. There are no application logs. When a crash dump is created, it is inconclusive, and the process cycles until the service agent disables it.
Those first four instances? They operate just fine. My client manager, manages them just fine, and exercises them freely.
Change to a User Account, and all is fine.
So, what should I be looking for? I know this is a broad question. Each instance of the image is it's own service. If I create them all at once, I tend to make each service depend on its younger sibling, to establish a start up order, but the dependency isn't necessary.
I thought this was related to The difference between the 'Local System' account and the 'Network Service' account?, and tried to piggyback onto that, but someone correct me. So here it is on its own.
I run a powershell script that executes a series of nssm command lines to install and manage the service details.
when it is a AD Account everything is identical, and they all run fine.
The application does get somewhere. All the log files that the app creates get created, but nothing gets written to them.
Stdout and Stderr are routed to their own files, and haven't revealed anything.
For what it is worth, this is my Add-Service function
function Add-Service {
Param (
[string]$serviceName,
[string]$dependsOn,
[string]$exePath,
[switch]$SysLocal = $false,
[string]$Username,
[string]$Password,
[string]$runIn,
[string[]]$parameters
)
$stdOutErrFile="$serviceName.log"
Write-Host "Creating service $serviceName, with $parameters"
& $nssm install $serviceName "$exePath"
& $nssm set $serviceName AppParameters "$parameters"
& $nssm set $serviceName AppDirectory "$runIn"
& $nssm set $serviceName Start SERVICE_AUTO_START
if ($dependsOn -ne "") {
& $nssm set $serviceName DependOnService $dependsOn
}
& $nssm set $serviceName Type SERVICE_WIN32_OWN_PROCESS
& $nssm set $serviceName AppPriority NORMAL_PRIORITY_CLASS
& $nssm set $serviceName AppNoConsole 1
& $nssm set $serviceName AppStdout (Join-Path $logsDir $stdOutErrFile)
& $nssm set $serviceName AppStdoutCreationDisposition 2
& $nssm set $serviceName AppStderr (Join-Path $logsDir $stdOutErrFile)
& $nssm set $serviceName AppStderrCreationDisposition 2
& $nssm set $serviceName AppThrottle 1500
& $nssm set $serviceName AppExit Default Restart
& $nssm set $serviceName AppRestartDelay 2000
Set-ItemProperty -Path "Registry::HKLM\System\CurrentControlSet\Services\$serviceName\Parameters" -Name AppStopMethodSkip -Value 1
if ($SysLocal -eq $false) {
& $nssm set $serviceName ObjectName "$Username" "$Password"
} else {
& $nssm set $serviceName ObjectName "LOCALSYSTEM"
}
& $nssm set $serviceName AppEnvironmentExtra "SERVICE_NAME=$serviceName"
Write-Host "Starting service: $serviceName"
Start-Service $serviceName
}
There are no error messages returned. All output from nssm is normal responses for each command issued.