diff --git a/scripts/deploy-from-workstation.ps1 b/scripts/deploy-from-workstation.ps1 index fe839a54..a91f7445 100644 --- a/scripts/deploy-from-workstation.ps1 +++ b/scripts/deploy-from-workstation.ps1 @@ -215,6 +215,7 @@ function Start-RegistryTunnel { param([int]$LocalPort) $sshPath = (Get-Command ssh -ErrorAction Stop).Source + $curlPath = (Get-Command curl.exe -ErrorAction Stop).Source $startInfo = [Diagnostics.ProcessStartInfo]::new() $startInfo.FileName = $sshPath $startInfo.UseShellExecute = $false @@ -223,6 +224,7 @@ function Start-RegistryTunnel { '-N', '-i', $keyFullPath, '-o', 'BatchMode=yes', + '-o', 'ConnectTimeout=10', '-o', 'ExitOnForwardFailure=yes', '-o', 'ServerAliveInterval=15', '-L', "127.0.0.1:${LocalPort}:127.0.0.1:5000", @@ -237,14 +239,18 @@ function Start-RegistryTunnel { if ($process.HasExited) { throw 'SSH 增量传输隧道启动失败。' } - try { - Invoke-WebRequest -Uri "http://127.0.0.1:$LocalPort/v2/" -TimeoutSec 1 | Out-Null + & $curlPath ` + --fail ` + --silent ` + --show-error ` + --max-time 1 ` + "http://127.0.0.1:$LocalPort/v2/" 2>$null | Out-Null + if ($LASTEXITCODE -eq 0) { return $process } - catch { - Start-Sleep -Milliseconds 500 - $attempt++ - } + + Start-Sleep -Milliseconds 500 + $attempt++ } $process.Kill()