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 package main
import ( import (
"bytes"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
@ -288,22 +290,28 @@ func runMinio() (*exec.Cmd, error) {
return nil, err return nil, err
} }
logfile, err := os.Create(filepath.Join(cfgdir, "output")) out := bytes.NewBuffer(nil)
if err != nil {
return nil, err
}
cmd := exec.Command("minio", cmd := exec.Command("minio",
"--config-folder", cfgdir, "--config-folder", cfgdir,
"--address", "127.0.0.1:9000", "--address", "127.0.0.1:9000",
"server", dir) "server", dir)
cmd.Stdout = logfile cmd.Stdout = out
cmd.Stderr = logfile cmd.Stderr = out
err = cmd.Start() err = cmd.Start()
if err != nil { if err != nil {
return nil, err 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 return cmd, nil
} }