| 99 | } |
| 100 | |
| 101 | func waitAndCleanup(host string, port string) (func() error, error) { |
| 102 | cmd := be.Command("wait-and-cleanup", host, port) |
| 103 | stdin, err := cmd.StdinPipe() |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | // Set up the command to run as a detached process |
| 108 | detach(cmd) |
| 109 | resultCh := make(chan *resultType) |
| 110 | go func() { |
| 111 | out, err := cmd.CombinedOutput() |
| 112 | resultCh <- &resultType{ |
| 113 | out: out, |
| 114 | err: err, |
| 115 | } |
| 116 | }() |
| 117 | return func() error { |
| 118 | stdin.Close() |
| 119 | result := <-resultCh |
| 120 | if result.err != nil { |
| 121 | return fmt.Errorf("unable to finish %v: %s\n%s", cmd.Path, result.err, string(result.out)) |
| 122 | } |
| 123 | return verify("") |
| 124 | }, nil |
| 125 | } |
| 126 | |
| 127 | func run(cmd *exec.Cmd) error { |
| 128 | out, err := cmd.CombinedOutput() |