jabbera / my-vsts-tasks

20 stars 18 forks source link

Services fail to stop, but say success - fail to start saying that the name can't be found. #48

Open nPowers opened 5 years ago

nPowers commented 5 years ago

I have 2 services to stop, then do a deployment and start them back. The stop task, says it has stopped with a success. But the deployment fails saying "files in use". Presumably because the services are not actually stopped. I have no access to the servers to prove that. On stopping the same named services, it fails telling me that the services are not found. Ideas?

The service names have been confirmed with server admins. I am using the Group deployment option.

Log for starting: No services match the name: KenticoCMSScheduler(staging.xxxxxxxx.com)

Log for stopping: 2019-06-26T00:15:01.1693392Z ##[section]Starting: Stop Windows Service: KenticoCMSScheduler(preprod.xxxxxxxx.com) 2019-06-26T00:15:01.1894694Z ============================================================================== 2019-06-26T00:15:01.1894783Z Task : Stop Windows Service 2019-06-26T00:15:01.1894814Z Description : Stop a windows service. 2019-06-26T00:15:01.1894841Z Version : 8.0.0 2019-06-26T00:15:01.1894890Z Author : Michael Barry 2019-06-26T00:15:01.1894917Z Help : More Information 2019-06-26T00:15:01.1894966Z ============================================================================== 2019-06-26T00:15:02.7991974Z Stopping Windows Service: and setting startup type to: Disabled. Kill: true 2019-06-26T00:15:02.9336119Z ##[section]Finishing: Stop Windows Service: KenticoCMSScheduler(preprod.xxxxxxxx.com)

jabbera commented 5 years ago

If you set a variable called: system.debug to true and rerun you should get a better log.

As for the service not releasing in use files, it’s typically a bug in the service. All threads need to be stopped before returning control to the service handler. https://stackoverflow.com/questions/5801147/service-is-stopped-but-process-remains-for-a-minute

If you don’t own the source code you can but a 2-3 minute delay in after the stop but before they copy.

nPowers commented 5 years ago

Agree on the hung files, we can't seem to stop services in the release tasks. We have no rights to alter our VSTS instance online nor see production server services, logs or details. Here's the debug:

2019-06-26T02:24:36.6162445Z ##[debug]Evaluating succeeded: 2019-06-26T02:24:36.6162619Z ##[debug]=> True 2019-06-26T02:24:36.6162806Z ##[debug]Result: True 2019-06-26T02:24:36.6162989Z ##[section]Starting: Start Windows Service: KenticoCMSScheduler(staging.xxxxxx.com) 2019-06-26T02:24:36.6358008Z ============================================================================== 2019-06-26T02:24:36.6358106Z Task : Start Windows Service 2019-06-26T02:24:36.6358137Z Description : Start a windows service. 2019-06-26T02:24:36.6358164Z Version : 8.0.0 2019-06-26T02:24:36.6358195Z Author : Michael Barry 2019-06-26T02:24:36.6358235Z Help : More Information 2019-06-26T02:24:36.6358267Z ============================================================================== 2019-06-26T02:24:38.1987842Z ##[debug]VstsTaskSdk 0.6.4 commit a074a158dbd70b5a72d1295ee42684c30a262b19 2019-06-26T02:24:38.2782510Z ##[debug]Entering C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsService.ps1. 2019-06-26T02:24:38.3070079Z ##[debug]Env:INPUT_SERVICENAMES: 'KenticoCMSScheduler(staging.xxxxxx.com)' 2019-06-26T02:24:38.3097822Z ##[debug]Env:INPUT_INSTANCENAME (empty) 2019-06-26T02:24:38.3208735Z ##[debug]Env:INPUT_WAITTIMEOUTINSECONDS: '120' 2019-06-26T02:24:38.3209570Z ##[debug]Env:INPUT_STARTUPTYPE: 'Automatic' 2019-06-26T02:24:38.3235734Z ##[debug]Env:INPUT_DEPLOYMENTGROUP: 'true' 2019-06-26T02:24:38.3247247Z ##[debug] Converted to bool: True 2019-06-26T02:24:38.3274500Z Starting Windows Services KenticoCMSScheduler(staging.xxxxxx.com) and setting startup type to: Automatic. 2019-06-26T02:24:38.4149820Z ##[debug]Leaving C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsService.ps1. 2019-06-26T02:24:38.4177613Z ##[debug]Caught exception from task script. 2019-06-26T02:24:38.4212564Z ##[debug]Error record: 2019-06-26T02:24:38.4837623Z ##[debug]StartStopServicesArray : No services match the name: KenticoCMSScheduler(staging.xxxxxx.com) 2019-06-26T02:24:38.4851109Z ##[debug]At C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsService.ps1:23 char:9 2019-06-26T02:24:38.4865795Z ##[debug]+ StartStopServicesArray $serviceNamesArray $instanceName $star ... 2019-06-26T02:24:38.4879955Z ##[debug]+ ~~~~~~~~~~~~~ 2019-06-26T02:24:38.4894918Z ##[debug] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException 2019-06-26T02:24:38.4913495Z ##[debug] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,StartStopServicesArray 2019-06-26T02:24:38.4933323Z ##[debug] 2019-06-26T02:24:38.4962793Z ##[debug]Script stack trace: 2019-06-26T02:24:38.5024529Z ##[debug]at , C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsServiceIntern.ps1: line 18 2019-06-26T02:24:38.5039800Z ##[debug]at StartStopServicesArray, C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsServiceIntern.ps1: line 9 2019-06-26T02:24:38.5055812Z ##[debug]at , C:\deploy1_work_tasks\StartWindowsService_bf65dd9d-18cb-40d9-9254-f3ac527428ef\8.0.0\StartWindowsService.ps1: line 23 2019-06-26T02:24:38.5072078Z ##[debug]at , : line 1 2019-06-26T02:24:38.5092739Z ##[debug]at , : line 22 2019-06-26T02:24:38.5108278Z ##[debug]at , : line 18 2019-06-26T02:24:38.5122897Z ##[debug]at , : line 1 2019-06-26T02:24:38.5150114Z ##[debug]Exception: 2019-06-26T02:24:38.5208855Z ##[debug]Microsoft.PowerShell.Commands.WriteErrorException: No services match the name: KenticoCMSScheduler(staging.xxxxxx.com) 2019-06-26T02:24:38.5526010Z ##[error]No services match the name: KenticoCMSScheduler(staging.xxxxxx.com) 2019-06-26T02:24:38.5534646Z ##[debug]Processed: ##vso[task.logissue type=error]No services match the name: KenticoCMSScheduler(staging.xxxxxx.com) 2019-06-26T02:24:38.5632961Z ##[debug]Processed: ##vso[task.complete result=Failed] 2019-06-26T02:24:38.5835508Z ##[section]Finishing: Start Windows Service: KenticoCMSScheduler(staging.xxxxxx.com)

nPowers commented 5 years ago

Bump

jabbera commented 5 years ago

Sorry, the script is pretty straight forward. For some reason https://github.com/jabbera/my-vsts-tasks/blob/master/Extensions/WindowsServiceReleaseTasks/Src/Tasks/StopWindowsService/StopWindowsServiceIntern.ps1#L16

Is not returning anything. It could be due to access or the service not existing. Without access to the server you are likely going to have a hard time resolving the issue.