fix(host-deployer): windows 2008 Out-File IOException

debug log cause windows 2008 IOException, multi process open log file.
This commit is contained in:
wanyaoqi
2023-01-09 13:57:10 +08:00
parent b107fbf1fe
commit 78a913fded
2 changed files with 3 additions and 9 deletions
+1 -1
View File
@@ -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"),
+2 -8
View File
@@ -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
`