From 50f69d4c5caa5bd6047c7cbe8478421ced82db1e Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 10 Jul 2026 13:15:09 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9A=94=E7=A6=BB=20Windows=20=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=A0=87=E5=87=86=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 启动图形节点时重定向标准输出和错误,避免继承 trans 管道导致受控 CLI 丢失终态。 Co-Authored-By: Claude Opus 4.7 --- scripts/src/hwlab-hwpod-node.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/src/hwlab-hwpod-node.ts b/scripts/src/hwlab-hwpod-node.ts index 4ec96907..a4770959 100644 --- a/scripts/src/hwlab-hwpod-node.ts +++ b/scripts/src/hwlab-hwpod-node.ts @@ -442,6 +442,7 @@ function applyDesktop(spec: HwpodNodeSpec, artifact: ArtifactBundle, credential: scriptPath: spec.runtime.scriptPath, configPath: spec.runtime.configPath, credentialPath: spec.runtime.credentialPath, + logPath: spec.runtime.logPath, probeLauncherPath: spec.python.probeLauncherPath, guiLauncherPath: spec.python.guiLauncherPath, launcherArgs: spec.python.launcherArgs, @@ -565,6 +566,7 @@ $root = [string]$payload.runtimeRoot $scriptPath = [string]$payload.scriptPath $configPath = [string]$payload.configPath $credentialPath = [string]$payload.credentialPath +$logPath = [string]$payload.logPath $probe = [string]$payload.probeLauncherPath $gui = [string]$payload.guiLauncherPath $launcherArgs = @($payload.launcherArgs | ForEach-Object { [string]$_ }) @@ -572,7 +574,7 @@ if (-not (Test-Path $probe)) { throw "Python probe launcher missing: $probe" } if (-not (Test-Path $gui)) { throw "Python GUI launcher missing: $gui" } $versionOut = @(& $probe @launcherArgs -c "import sys;import tkinter;print(sys.version);print(sys.executable);print(tkinter.TkVersion)" 2>&1) if ($LASTEXITCODE -ne 0 -or (($versionOut -join "\`n") -notlike "*$($payload.expectedVersionPrefix)*")) { throw "Python version mismatch: $($versionOut -join ' | ')" } -New-Item -ItemType Directory -Force -Path $root, (Split-Path -Parent $configPath), (Split-Path -Parent $credentialPath) | Out-Null +New-Item -ItemType Directory -Force -Path $root, (Split-Path -Parent $configPath), (Split-Path -Parent $credentialPath), (Split-Path -Parent $logPath) | Out-Null $old = @(Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -and $_.CommandLine.Contains($scriptPath) }) foreach ($proc in $old) { Stop-Process -Id $proc.ProcessId -Force -ErrorAction SilentlyContinue } Start-Sleep -Milliseconds 500 @@ -588,7 +590,9 @@ $argText = (($launcherArgs | ForEach-Object { '"' + ($_ -replace '"','\"') + '"' $runCommand = '"' + $gui + '" ' + $argText + ' "' + $scriptPath + '"' $null = New-Item -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' -Force Set-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' -Name ([string]$payload.runKeyName) -Value $runCommand -Start-Process -FilePath $gui -ArgumentList @($launcherArgs + @($scriptPath)) -WorkingDirectory $root +$stdoutPath = $logPath + '.stdout' +$stderrPath = $logPath + '.stderr' +Start-Process -FilePath $gui -ArgumentList @($launcherArgs + @($scriptPath)) -WorkingDirectory $root -RedirectStandardOutput $stdoutPath -RedirectStandardError $stderrPath Start-Sleep -Seconds 3 $processes = @(Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -and $_.CommandLine.Contains($scriptPath) }) $explorerSessions = @(Get-Process explorer -ErrorAction SilentlyContinue | Select-Object -ExpandProperty SessionId -Unique)