diff --git a/jobs/docker-windows/spec b/jobs/docker-windows/spec index 6cb204d..124300a 100644 --- a/jobs/docker-windows/spec +++ b/jobs/docker-windows/spec @@ -3,6 +3,7 @@ name: docker-windows templates: pre-start.ps1: bin/pre-start.ps1 + drain.ps1: bin/drain.ps1 packages: - docker-windows diff --git a/jobs/docker-windows/templates/drain.ps1 b/jobs/docker-windows/templates/drain.ps1 new file mode 100644 index 0000000..673a6a5 --- /dev/null +++ b/jobs/docker-windows/templates/drain.ps1 @@ -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