reset interrupted runs before retry in the dev launcher
proxy timeouts can kill a build mid-flight, leaving orphaned containers on the channel ports, dangling build cache, and half-written clones. clean those on every start, scoped to the channel and keeping the DB volume, so a re-run starts from a clean slate.
This commit is contained in:
@@ -48,6 +48,40 @@ param(
|
|||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
# Reset leftovers from an interrupted or timed-out prior run so the retry starts
|
||||||
|
# clean. Proxy bottlenecks can kill a build mid-flight, leaving orphaned
|
||||||
|
# containers holding the channel ports, dangling build cache from the partial
|
||||||
|
# build, and sometimes a half-written clone. This is scoped to the channel and
|
||||||
|
# is non-destructive to data: the compose down keeps named volumes (the DB), and
|
||||||
|
# only dangling build cache is pruned - never tagged images or volumes.
|
||||||
|
function Clear-InterruptedRun {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)][string]$Project,
|
||||||
|
[Parameter(Mandatory)][string]$Target
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# A directory that exists but has no valid .git is a broken/partial clone;
|
||||||
|
# remove it so the clone below can start fresh instead of failing.
|
||||||
|
if ((Test-Path $Target) -and -not (Test-Path (Join-Path $Target '.git'))) {
|
||||||
|
Write-Host "==> Removing incomplete clone at $Target" -ForegroundColor Cyan
|
||||||
|
Remove-Item -Path $Target -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Plain https URL. No token in the URL: Git Credential Manager injects the
|
# Plain https URL. No token in the URL: Git Credential Manager injects the
|
||||||
# stored GitHub credential for github.com, so clone/fetch authenticate against
|
# stored GitHub credential for github.com, so clone/fetch authenticate against
|
||||||
# the private repo without anything sensitive touching this script or disk.
|
# the private repo without anything sensitive touching this script or disk.
|
||||||
@@ -63,6 +97,9 @@ if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
|||||||
throw 'git is required. Install Git for Windows (winget install Git.Git) and re-run.'
|
throw 'git is required. Install Git for Windows (winget install Git.Git) and re-run.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$project = if ($Channel -eq 'edge') { 'shopdb-edge' } else { 'shopdb-stable' }
|
||||||
|
Clear-InterruptedRun -Project $project -Target $target
|
||||||
|
|
||||||
if (Test-Path (Join-Path $target '.git')) {
|
if (Test-Path (Join-Path $target '.git')) {
|
||||||
Write-Host "==> Updating existing clone" -ForegroundColor Cyan
|
Write-Host "==> Updating existing clone" -ForegroundColor Cyan
|
||||||
git -C $target fetch origin $branch
|
git -C $target fetch origin $branch
|
||||||
|
|||||||
Reference in New Issue
Block a user