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

Commit

Permalink
Add drain script for docker-windows job
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Moss committed Nov 4, 2019
1 parent 05411cd commit 6beed01
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions jobs/docker-windows/spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: docker-windows

templates:
pre-start.ps1: bin/pre-start.ps1
drain.ps1: bin/drain.ps1

packages:
- docker-windows
Expand Down
19 changes: 19 additions & 0 deletions jobs/docker-windows/templates/drain.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +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' })
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") {
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"
}
echo "Docker service drained; Exit 0" | Out-File -Encoding ASCII -Append "c:\var\vcap\sys\log\docker-windows\drain.log"

"0"
Exit 0

0 comments on commit 6beed01

Please sign in to comment.