don't pipe restarted stuff through the ui

This commit is contained in:
Megan Marsh 2017-11-09 14:44:26 -08:00
parent d71bc34dfc
commit a739623d9b

View File

@ -3,7 +3,7 @@ package restart
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io"
"log" "log"
"strings" "strings"
"sync" "sync"
@ -201,13 +201,18 @@ var waitForCommunicator = func(p *Provisioner) error {
} }
// this is the non-user-configurable check that powershell // this is the non-user-configurable check that powershell
// modules have loaded // modules have loaded
cmdModuleLoad := &packer.RemoteCmd{Command: DefaultRestartCheckCommand} var buf bytes.Buffer
var buf, buf2 bytes.Buffer cmdModuleLoad := &packer.RemoteCmd{
cmdModuleLoad.Stdout = &buf Command: DefaultRestartCheckCommand,
cmdModuleLoad.Stdout = io.MultiWriter(cmdModuleLoad.Stdout, &buf2) Stdin: nil,
Stdout: &buf,
Stderr: &buf}
cmdModuleLoad.StartWithUi(p.comm, p.ui) // cmdModuleLoad.StartWithUi(p.comm, p.ui)
stdoutToRead := buf2.String() p.comm.Start(cmdModuleLoad)
cmdModuleLoad.Wait()
stdoutToRead := buf.String()
if !strings.Contains(stdoutToRead, "restarted.") { if !strings.Contains(stdoutToRead, "restarted.") {
log.Printf("echo didn't succeed; retrying...") log.Printf("echo didn't succeed; retrying...")
continue continue