Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
Remove docker service when draining
Browse files Browse the repository at this point in the history
This is necessary because the service is not managed by BOSH as a
regular ctl script, but instead it's installed in the pre-start.
  • Loading branch information
Ben Moss committed Dec 10, 2019
1 parent 7f7aad7 commit 131ddae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions jobs/docker-windows/templates/drain.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
$ErrorActionPreference = "Stop";

echo "Querying docker service" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
$docker=(Get-Service | where { $_.Name -eq 'docker' })
$docker = Get-WmiObject -Class Win32_Service -Filter "Name='docker'"
if ($docker -eq $null) {
echo "Docker service not found; Exiting 0" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
"0"
Exit 0
}

echo "Docker service found" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
If ($docker.Status -Eq "Running") {
If ($docker.State -Eq "Running") {
echo "Docker service running; Stopping" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
Stop-Service $docker | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
$docker.StopService() | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"
}
$service.Delete()
echo "Docker service drained; Exit 0" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"

"0"
Expand Down

0 comments on commit 131ddae

Please sign in to comment.