param( [string]$KeyFile = '', [string]$ApiHost = '' ) $ErrorActionPreference = 'Stop' $root = Split-Path -Parent $PSScriptRoot Set-Location $root . (Join-Path $PSScriptRoot 'tencent-prod-env.ps1') $prodEnv = Read-TencentProdEnv -Root $root if (-not $ApiHost) { $ApiHost = "ubuntu@$($prodEnv.API_IP)" } if (-not $KeyFile) { $KeyFile = Join-Path $root 'deploy\id_rsa_tencent' } if (-not (Test-Path $KeyFile)) { Write-Error "SSH key not found: $KeyFile" } $sshOpts = @('-i', $KeyFile, '-o', 'StrictHostKeyChecking=accept-new', '-o', 'ConnectTimeout=20') $scriptPath = Join-Path $root 'scripts\setup-prod-redis.sh' Write-Host "`n=== Deploy full stack ===" -ForegroundColor Cyan & (Join-Path $PSScriptRoot 'deploy-prod-all.ps1') -KeyFile $KeyFile -ApiHost $ApiHost -H5Host "root@$($prodEnv.H5_IP)" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "`n=== Configure Redis on test-api ===" -ForegroundColor Cyan & scp @sshOpts $scriptPath "${ApiHost}:/tmp/setup-prod-redis.sh" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } & ssh @sshOpts $ApiHost "chmod +x /tmp/setup-prod-redis.sh && bash /tmp/setup-prod-redis.sh && rm -f /tmp/setup-prod-redis.sh" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Write-Host "`n=== Verify public health ===" -ForegroundColor Cyan curl -sf "https://www.xdjchuanhui.com/api/health" Write-Host "" Write-Host "`n=== Deploy + Redis complete ===" -ForegroundColor Green