fix dialing of npipe

pull/17694/head
absolutelightning 1 year ago
parent fd4ceeda17
commit fd75fb78cf

@ -17,39 +17,32 @@ func makeBootstrapPipe(bootstrapJSON []byte) (string, error) {
pipeFile := filepath.Join(os.TempDir(), pipeFile := filepath.Join(os.TempDir(),
fmt.Sprintf("envoy-%x-bootstrap.json", time.Now().UnixNano()+int64(os.Getpid()))) fmt.Sprintf("envoy-%x-bootstrap.json", time.Now().UnixNano()+int64(os.Getpid())))
pipeConn, err := npipe.Dial(pipeFile) binary, args, err := execArgs("connect", "envoy", "pipe-bootstrap", pipeFile)
if err != nil { if err != nil {
return tempFile, err return pipeFile, err
} }
defer pipeConn.close() // Dial the named pipe
pipeConn, err := npipe.Dial(pipeFile)
binary, args, err := execArgs("connect", "envoy", "pipe-bootstrap", pipeFile)
if err != nil { if err != nil {
return pipeFile, err return pipeFile, err
} }
defer pipeConn.Close()
// Start the command to connect to the named pipe // Start the command to connect to the named pipe
cmd := exec.Command(binary, args...) cmd := exec.Command(binary, args...)
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
stdin, err := cmd.StdinPipe() cmd.Stdin = pipeConn
if err != nil {
return pipeFile, err
}
// Start the command and write the config // Start the command
err = cmd.Start() err = cmd.Start()
if err != nil { if err != nil {
return pipeFile, err return pipeFile, err
} }
// Write the config // Write the config
_, err = stdin.Write(bootstrapJSON) _, err = pipeConn.Write(bootstrapJSON)
if err != nil {
return pipeFile, err
}
err = stdin.Close()
if err != nil { if err != nil {
return pipeFile, err return pipeFile, err
} }

Loading…
Cancel
Save