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,24 +31,27 @@ $cn = New-Object System.Data.SqlClient.SqlConnection $verify; $cn.Open()
|
|||||||
$c = $cn.CreateCommand(); $c.CommandText = "SELECT DB_NAME()"; $db = $c.ExecuteScalar(); $cn.Close()
|
$c = $cn.CreateCommand(); $c.CommandText = "SELECT DB_NAME()"; $db = $c.ExecuteScalar(); $cn.Close()
|
||||||
Write-Host " verify snolla->VDS stostayer OK (db=$db)" -ForegroundColor Green
|
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
|
Write-Host "`n=== F2. repoint stostayer.old web.config ===" -ForegroundColor Cyan
|
||||||
Copy-Item $wcPath "$wcPath.bak-pre-vds-$(Get-Date -Format yyyyMMdd)" -Force
|
if ($src -match '(?i)Data Source=localhost') {
|
||||||
$xml = [xml](Get-Content $wcPath)
|
Copy-Item $wcPath "$wcPath.bak-pre-vds-$(Get-Date -Format yyyyMMdd)" -Force
|
||||||
$node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'MoreThenCmsEntities' }
|
$xml = [xml](Get-Content $wcPath)
|
||||||
$new = ($node.connectionString -replace '(?i)Data Source=localhost(,1433)?','Data Source=mssql.kzntsv.site,1433')
|
$node = $xml.configuration.connectionStrings.add | Where-Object { $_.name -eq 'MoreThenCmsEntities' }
|
||||||
if ($new -notmatch 'TrustServerCertificate') { $new = $new.TrimEnd(';') + ';TrustServerCertificate=True' }
|
$new = ($node.connectionString -replace '(?i)Data Source=localhost(,1433)?','Data Source=mssql.kzntsv.site,1433')
|
||||||
$node.connectionString = $new
|
if ($new -notmatch 'TrustServerCertificate') { $new = $new.TrimEnd(';') + ';TrustServerCertificate=True' }
|
||||||
$xml.Save($wcPath)
|
$node.connectionString = $new
|
||||||
Write-Host " web.config -> mssql.kzntsv.site (backup alongside)" -ForegroundColor Green
|
$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
|
Write-Host "`n=== F3. restart pool stostayer.old + smoke :8091 ===" -ForegroundColor Cyan
|
||||||
Restart-WebAppPool -Name 'stostayer.old'
|
Restart-WebAppPool -Name 'stostayer.old'
|
||||||
Start-Sleep -Seconds 5
|
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"
|
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-*."
|
Write-Error "stostayer.old returned '$code' - repoint FAILED. Leaving MSSQL untouched. Rollback: restore web.config.bak-pre-vds-*."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user