1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

Output stderr when minio server failed

This commit is contained in:
Alexander Neumann 2015-12-20 18:09:35 +01:00
parent d5e36bd2f0
commit e96f28c536

View file

@ -3,7 +3,9 @@
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
@ -288,22 +290,28 @@ func runMinio() (*exec.Cmd, error) {
return nil, err
}
logfile, err := os.Create(filepath.Join(cfgdir, "output"))
if err != nil {
return nil, err
}
out := bytes.NewBuffer(nil)
cmd := exec.Command("minio",
"--config-folder", cfgdir,
"--address", "127.0.0.1:9000",
"server", dir)
cmd.Stdout = logfile
cmd.Stderr = logfile
cmd.Stdout = out
cmd.Stderr = out
err = cmd.Start()
if err != nil {
return nil, err
}
go func() {
err := cmd.Wait()
if err != nil {
fmt.Fprintf(os.Stderr, "error running minio server: %v, output:\n", err)
io.Copy(os.Stderr, out)
os.Exit(12)
}
}()
return cmd, nil
}