From 78a913fdedd3be2611fb7a669dcfb3ed23c1300c Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 9 Jan 2023 13:35:40 +0800 Subject: [PATCH] fix(host-deployer): windows 2008 Out-File IOException debug log cause windows 2008 IOException, multi process open log file. --- pkg/hostman/guestfs/fsdriver/windows.go | 2 +- pkg/hostman/guestfs/fsdriver/winscripts.go | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pkg/hostman/guestfs/fsdriver/windows.go b/pkg/hostman/guestfs/fsdriver/windows.go index 196c4be623..81633dc54a 100644 --- a/pkg/hostman/guestfs/fsdriver/windows.go +++ b/pkg/hostman/guestfs/fsdriver/windows.go @@ -595,7 +595,7 @@ func (w *SWindowsRootFs) DeployTelegraf(config string) (bool, error) { strings.Join([]string{ `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe`, ` -executionpolicy bypass %SystemRoot%\telegraf.ps1`, - fmt.Sprintf(" '%s' '%s' %s", telegrafBinaryPath, telegrafConfPath, w.guestDebugLogPath), + fmt.Sprintf(" '%s' '%s' >> %s_telegraf", telegrafBinaryPath, telegrafConfPath, w.guestDebugLogPath), }, ""), `del %SystemRoot%\telegraf.ps1`, w.MakeGuestDebugCmd("setup telegraf step 2"), diff --git a/pkg/hostman/guestfs/fsdriver/winscripts.go b/pkg/hostman/guestfs/fsdriver/winscripts.go index 022996cb4a..a9d560d479 100644 --- a/pkg/hostman/guestfs/fsdriver/winscripts.go +++ b/pkg/hostman/guestfs/fsdriver/winscripts.go @@ -522,14 +522,8 @@ mtw_main(); const winTelegrafSetupPowerShellScript = ` $telegraf = $args[0] $telegraf_conf = $args[1] -$logpath = $args[2] -if ($logpath) { - & $telegraf --service install --config $telegraf_conf 2>&1 | Out-File $logpath -Append -Encoding Default - net start telegraf | Out-File $logpath -Append -Encoding Default -} else { - & $telegraf --service install --config $telegraf_conf 2>&1 - net start telegraf -} +& $telegraf --service install --config $telegraf_conf +net start telegraf `