keep launcher cleanup from aborting on docker stderr warnings
docker/compose emit warnings on stderr (e.g. nothing to remove), which tripped ErrorActionPreference=Stop and killed the run before the clone. soften the preference around the best-effort cleanup steps.
This commit is contained in:
@@ -61,16 +61,27 @@ function Clear-InterruptedRun {
|
||||
)
|
||||
|
||||
if (Get-Command docker -ErrorAction SilentlyContinue) {
|
||||
# Only try compose down when the engine is actually responding, otherwise
|
||||
# skip quietly - a fresh box may not have Docker started yet.
|
||||
docker info *> $null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "==> Cleaning up any interrupted '$Project' stack" -ForegroundColor Cyan
|
||||
# --remove-orphans clears containers left by a killed build; volumes are
|
||||
# intentionally kept so the DB survives a retry.
|
||||
docker compose -p $Project down --remove-orphans *> $null
|
||||
# Reclaim only dangling build cache from failed/partial builds.
|
||||
docker builder prune -f *> $null
|
||||
# docker/compose write warnings to stderr (e.g. "No resource found to
|
||||
# remove"), which would trip $ErrorActionPreference='Stop' and abort the
|
||||
# whole run. These cleanup steps are best-effort, so soften the preference
|
||||
# and swallow all streams for their duration.
|
||||
$previous = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
# Only try compose down when the engine is actually responding, otherwise
|
||||
# skip quietly - a fresh box may not have Docker started yet.
|
||||
docker info *> $null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "==> Cleaning up any interrupted '$Project' stack" -ForegroundColor Cyan
|
||||
# --remove-orphans clears containers left by a killed build; volumes are
|
||||
# intentionally kept so the DB survives a retry.
|
||||
docker compose -p $Project down --remove-orphans *> $null
|
||||
# Reclaim only dangling build cache from failed/partial builds.
|
||||
docker builder prune -f *> $null
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$ErrorActionPreference = $previous
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user