fix(decommission): smoke :8091 via curl --noproxy; idempotent F2
The F3 smoke false-failed: system VPN proxy swallows Invoke-WebRequest to localhost (wiki bug #7), returning empty -> gate aborted before E/M. Verified out-of-band: :8091 -> HTTP 200 (real stostayer.old page), so the repoint actually succeeded. Switched smoke to curl.exe --noproxy. Made F2 idempotent (only repoint if still localhost) so re-runs don't clobber the original localhost backup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,8 +31,9 @@ $cn = New-Object System.Data.SqlClient.SqlConnection $verify; $cn.Open()
|
||||
$c = $cn.CreateCommand(); $c.CommandText = "SELECT DB_NAME()"; $db = $c.ExecuteScalar(); $cn.Close()
|
||||
Write-Host " verify snolla->VDS stostayer OK (db=$db)" -ForegroundColor Green
|
||||
|
||||
# ---------- F2: repoint web.config ----------
|
||||
# ---------- F2: repoint web.config (idempotent) ----------
|
||||
Write-Host "`n=== F2. repoint stostayer.old web.config ===" -ForegroundColor Cyan
|
||||
if ($src -match '(?i)Data Source=localhost') {
|
||||
Copy-Item $wcPath "$wcPath.bak-pre-vds-$(Get-Date -Format yyyyMMdd)" -Force
|
||||
$xml = [xml](Get-Content $wcPath)
|
||||
$node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'MoreThenCmsEntities' }
|
||||
@@ -41,14 +42,16 @@ if ($new -notmatch 'TrustServerCertificate') { $new = $new.TrimEnd(';') + ';Trus
|
||||
$node.connectionString = $new
|
||||
$xml.Save($wcPath)
|
||||
Write-Host " web.config -> mssql.kzntsv.site (backup alongside)" -ForegroundColor Green
|
||||
} else { Write-Host " already pointed at VDS - skip (original backup preserved)" -ForegroundColor Green }
|
||||
|
||||
# ---------- F3: restart pool + smoke ----------
|
||||
# ---------- F3: restart pool + smoke (proxy-bypassed) ----------
|
||||
Write-Host "`n=== F3. restart pool stostayer.old + smoke :8091 ===" -ForegroundColor Cyan
|
||||
Restart-WebAppPool -Name 'stostayer.old'
|
||||
Start-Sleep -Seconds 5
|
||||
$code = try { (Invoke-WebRequest "http://localhost:8091/" -UseBasicParsing -TimeoutSec 30).StatusCode } catch { $_.Exception.Response.StatusCode.value__ }
|
||||
# system VPN proxy swallows localhost (wiki bug #7) -> curl.exe --noproxy bypasses it
|
||||
$code = (& curl.exe -s -o NUL -w "%{http_code}" --noproxy "*" --max-time 30 http://localhost:8091/)
|
||||
Write-Host " :8091 -> HTTP $code"
|
||||
if ((-not $code) -or ($code -ge 500)) {
|
||||
if ((-not ($code -match '^\d+$')) -or ([int]$code -eq 0) -or ([int]$code -ge 500)) {
|
||||
Write-Error "stostayer.old returned '$code' - repoint FAILED. Leaving MSSQL untouched. Rollback: restore web.config.bak-pre-vds-*."
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user