修复工作站增量发布隧道误判 (#24)
This commit is contained in:
parent
efc797e95e
commit
1cc6b76b68
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user