update
This commit is contained in:
44
AzA march 2026 - Kopie (18)/deploy/run_caddy_reload.ps1
Normal file
44
AzA march 2026 - Kopie (18)/deploy/run_caddy_reload.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
Write-Host '[AZA] Step 15 - Caddy Reload (force recreate)'
|
||||
|
||||
$composeFile = Join-Path $PSScriptRoot 'docker-compose.yml'
|
||||
if (-not (Test-Path $composeFile)) {
|
||||
throw "Compose file not found: $composeFile"
|
||||
}
|
||||
|
||||
# Ensure Docker engine is up
|
||||
& (Join-Path $PSScriptRoot 'docker_ensure.ps1')
|
||||
|
||||
# Recreate caddy to apply updated Caddyfile/.env
|
||||
Write-Host '[AZA] docker compose up -d --force-recreate caddy'
|
||||
# NOTE: Windows PowerShell can raise NativeCommandError for docker stderr even on success.
|
||||
# Use cmd.exe to avoid stderr being treated as a PowerShell error record.
|
||||
$cmd = 'docker compose -f "' + $composeFile + '" up -d --force-recreate caddy'
|
||||
$out = & cmd.exe /c ($cmd + ' 2>&1')
|
||||
$code = $LASTEXITCODE
|
||||
$out | Out-Host
|
||||
if ($code -ne 0) { throw "[AZA] FAIL: docker compose recreate caddy failed (exit=$code)" }
|
||||
|
||||
# Status
|
||||
Write-Host '[AZA] docker compose ps'
|
||||
& docker compose -f $composeFile ps 2>&1 | Out-Host
|
||||
|
||||
# Optional local HTTP check (local dev uses host port 18080 -> container 80)
|
||||
Write-Host '[AZA] Optional: test http://127.0.0.1:18080/health (via caddy)'
|
||||
$ok = $false
|
||||
for ($i = 0; $i -lt 8; $i++) {
|
||||
try {
|
||||
$r = Invoke-WebRequest -UseBasicParsing -Uri 'http://127.0.0.1:18080/health' -TimeoutSec 3
|
||||
Write-Host ('[AZA] http://127.0.0.1:18080/health StatusCode=' + $r.StatusCode)
|
||||
$ok = $true
|
||||
break
|
||||
} catch {
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
}
|
||||
if (-not $ok) {
|
||||
$tnc = Test-NetConnection -ComputerName 127.0.0.1 -Port 18080 | Select-Object ComputerName,RemotePort,TcpTestSucceeded
|
||||
Write-Host ('[AZA] WARN: http://127.0.0.1/health still failing. Port check: ' + ($tnc | Out-String).Trim())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user