|
|
|
|
@ -36,21 +36,30 @@ func Command(cmd *exec.Cmd) (result packer.Command, err error) {
|
|
|
|
|
select {
|
|
|
|
|
case <-cmdExited:
|
|
|
|
|
err = errors.New("plugin exited before we could connect")
|
|
|
|
|
return
|
|
|
|
|
case <-time.After(10 * time.Millisecond):
|
|
|
|
|
if line, err := out.ReadBytes('\n'); err == nil {
|
|
|
|
|
address = strings.TrimSpace(string(line))
|
|
|
|
|
done = true
|
|
|
|
|
}
|
|
|
|
|
done = true
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Make sure to reset err to nil
|
|
|
|
|
if line, lerr := out.ReadBytes('\n'); lerr == nil {
|
|
|
|
|
// Trim the address and reset the err since we were able
|
|
|
|
|
// to read some sort of address.
|
|
|
|
|
address = strings.TrimSpace(string(line))
|
|
|
|
|
err = nil
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If error is nil from previously, return now
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wait a bit
|
|
|
|
|
time.Sleep(10 * time.Millisecond)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client, err := rpc.Dial("tcp", address)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = packrpc.Command(client)
|
|
|
|
|
|