Skip to content

Commit

Permalink
Make service shutdown more robust
Browse files Browse the repository at this point in the history
- Prevent stopping services that do not exist
- Wait for the services to shut down before doing anything else

Signed-off-by: Samuli Seppänen <[email protected]>
  • Loading branch information
mattock committed Nov 15, 2016
1 parent efea46f commit a1012f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test-openvpn.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ Function Stop-Gui {
}

Function Stop-Openvpnservice {
Stop-Service OpenVPNService
Stop-Service OpenVPNServiceLegacy
foreach ($service in 'OpenVPNService', 'OpenVPNServiceLegacy') {
if (Get-Service -Erroraction Ignore $service) {
Stop-Service $service
(Get-Service $service).WaitForStatus('Stopped')
}
}
}

# Stop all openvpn-related processes
Expand Down

0 comments on commit a1012f3

Please sign in to comment.