Closed stephenpatten closed 7 years ago
Hi,
InstanceName in topshelf has a very specific connotation. (http://docs.topshelf-project.com/en/latest/configuration/config_api.html#instance-name)
Specify the instance name of the service, which is combined with the base service name and separated by a $. This is optional, and is only added if specified.
In your installation step you have the instance name as: DocumentReceiver which means your service is actually called: [BaseServiceName]$DocumentRetriever
I usually make InstanceName = $(Release.EnvironmentName) for supporting multiple instances on the same server.
Note: When starting\stopping you will need to use the ` to escape the $ sign in the service name.
Cheers, Mike
Hello,
I'm running the following tasks but for whatever reason the Start Windows Service fails to complete successfully.
Here are some of my requirements as I developed this:
Here is the output of the TFS Release Manager:
2017-01-25T01:07:23.4193356Z ##[section]Starting: Start Windows Service: DocumentReceiver 2017-01-25T01:07:25.0912108Z Starting Windows Services DocumentReceiver and setting startup type to: Automatic. Version: 2.16350.0 2017-01-25T01:07:25.1537187Z ScriptArguments: -serviceNames "DocumentReceiver" -startupType Automatic -waitTimeoutInSeconds 120 -killIfTimedOut false 2017-01-25T01:07:25.1693324Z Invoking deployment 2017-01-25T01:07:25.1693324Z Script Body: function StartStopServices( 2017-01-25T01:07:25.1693324Z [string][Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] $serviceNames, 2017-01-25T01:07:25.1693324Z [string][Parameter(Mandatory=$true)][ValidateSet("Manual", "Automatic")] $startupType, 2017-01-25T01:07:25.1693324Z [int][Parameter(Mandatory=$true)] $waitTimeoutInSeconds, 2017-01-25T01:07:25.1693324Z [string][Parameter(Mandatory=$true)] $killIfTimedOut 2017-01-25T01:07:25.1693324Z ) 2017-01-25T01:07:25.1693324Z { 2017-01-25T01:07:25.1693324Z [string[]] $servicesNamesArray = ($serviceNames -split ',' -replace '"').Trim() 2017-01-25T01:07:25.1693324Z $presentServicesArray = Get-Service | Where-Object { $servicesNamesArray -contains $.Name } 2017-01-25T01:07:25.1693324Z 2017-01-25T01:07:25.1693324Z if ($servicesNamesArray.Length -ne $presentServicesArray.Length) 2017-01-25T01:07:25.1693324Z { 2017-01-25T01:07:25.1693324Z $missingServiceNames = $servicesNamesArray | Where-Object { $presentServicesArrayNames -notcontains $ } 2017-01-25T01:07:25.1693324Z Write-Error "No such services: $missingServiceNames." 2017-01-25T01:07:25.1693324Z return -1; 2017-01-25T01:07:25.1693324Z } 2017-01-25T01:07:25.1693324Z 2017-01-25T01:07:25.1849624Z $presentServicesArray | % { Set-Service -Name $.Name -StartupType $startupType } 2017-01-25T01:07:25.1849624Z $presentServicesArray | Where-Object { $.Status -ne "Running" } | % { $.Start() } 2017-01-25T01:07:25.1849624Z $presentServicesArray | % { $.WaitForStatus("Running", [TimeSpan]::FromSeconds($waitTimeoutInSeconds)) } 2017-01-25T01:07:25.1849624Z } 2017-01-25T01:07:25.1849624Z with port 5985.
2017-01-25T01:07:35.7318621Z Deployment status for machine : Failed
2017-01-25T01:07:35.8256120Z Deployment failed on machine with following message : System.Exception: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: No such services: DocumentReceiver.
2017-01-25T01:07:36.1849800Z ##[error]Deployment on one or more machines failed.
Error returned from remote deployment.
2017-01-25T01:07:36.2006038Z ##[section]Finishing: Start Windows Service: DocumentReceiver
2017-01-25T01:07:25.1849624Z StartStopServices -serviceNames "DocumentReceiver" -startupType Automatic -waitTimeoutInSeconds 120 -killIfTimedOut false 2017-01-25T01:07:25.2474568Z Performing deployment in parallel on all the machines. 2017-01-25T01:07:25.2630891Z Deployment started for machine:
What is truly bizarre is that I can start the service through the snap in after the fail, and it works like a champ, go figure.
Thank you, Stephen