upd deploy

This commit is contained in:
beo3000 2026-03-01 20:03:31 +01:00
parent 535f3aca38
commit 3214fd5364
2 changed files with 72 additions and 62 deletions

View File

@ -1 +1 @@
1.2.4
1.2.5

View File

@ -129,22 +129,28 @@ Write-Host "=== Restart App Service ===" -ForegroundColor Cyan
az webapp restart --name $APP --resource-group $RG
Write-Host "=== Post-Deploy DB Validation ===" -ForegroundColor Cyan
Write-Host " Waiting for server to boot (~20s)..." -ForegroundColor DarkGray
$bootDeadline = (Get-Date).AddSeconds(45)
$serverReady = $false
while ((Get-Date) -lt $bootDeadline) {
$validationOk = $false
$keepValidating = $true
while ($keepValidating) {
$keepValidating = $false
Write-Host " Waiting for server to boot (~20s)..." -ForegroundColor DarkGray
$bootDeadline = (Get-Date).AddSeconds(45)
$serverReady = $false
while ((Get-Date) -lt $bootDeadline) {
Start-Sleep -Seconds 3
try {
$h = Invoke-RestMethod -Uri "$AppUrl/api/health" -Method GET -UseBasicParsing -TimeoutSec 5
if ($h.status -eq 'ok') { $serverReady = $true; break }
} catch { }
}
if (-not $serverReady) {
}
if (-not $serverReady) {
Write-Host " WARNING: Server did not respond within 45s" -ForegroundColor Red
}
}
$validationOk = $false
if ($serverReady -and $env:KA_NOTE_DEPLOY_API_KEY) {
if ($serverReady -and $env:KA_NOTE_DEPLOY_API_KEY) {
$authHeader = @{ Authorization = "Bearer $env:KA_NOTE_DEPLOY_API_KEY" }
$maxRetries = 6
for ($attempt = 1; $attempt -le $maxRetries; $attempt++) {
@ -168,20 +174,23 @@ if ($serverReady -and $env:KA_NOTE_DEPLOY_API_KEY) {
if (-not $validationOk) {
Write-Host " DB validation FAILED after $maxRetries attempts" -ForegroundColor Red
}
} elseif (-not $env:KA_NOTE_DEPLOY_API_KEY) {
} elseif (-not $env:KA_NOTE_DEPLOY_API_KEY) {
Write-Host " KA_NOTE_DEPLOY_API_KEY not set, skipping DB validation" -ForegroundColor Yellow
$validationOk = $true
}
}
if (-not $validationOk) {
if (-not $validationOk) {
$latestBackup = Get-ChildItem -Path $BackupDir -Filter "*.db" |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
Write-Host ""
Write-Host " !! DB appears empty or unreachable after deploy !!" -ForegroundColor Red
Write-Host " Pre-deploy backup: $($latestBackup.FullName)" -ForegroundColor Yellow
Write-Host ""
$answer = Read-Host " Restore backup to prod? (yes/no)"
if ($answer -eq 'yes') {
$answer = Read-Host " Restore backup to prod? (yes/no/retry)"
if ($answer -eq 'retry') {
Write-Host " Retrying validation..." -ForegroundColor Cyan
$keepValidating = $true
} elseif ($answer -eq 'yes') {
Write-Host " Uploading backup to prod..." -ForegroundColor Cyan
Invoke-WebRequest -Uri $KuduDbUrl `
-Method PUT `
@ -194,6 +203,7 @@ if (-not $validationOk) {
Write-Host " Restore skipped. Manual intervention required!" -ForegroundColor Red
exit 1
}
}
}
Write-Host "=== Done! $VERSION deployed ===" -ForegroundColor Green