service: return better error messages from executed commands.

This commit is contained in:
Daniel Theophanes
2015-03-14 08:14:25 -07:00
parent 32a574a9fb
commit 17f5541e81
7 changed files with 30 additions and 23 deletions

View File

@@ -9,6 +9,7 @@ package service
import (
"fmt"
"log/syslog"
"os/exec"
)
func newSysLogger(name string, errs chan<- error) (Logger, error) {
@@ -49,3 +50,12 @@ func (s sysLogger) Warningf(format string, a ...interface{}) error {
func (s sysLogger) Infof(format string, a ...interface{}) error {
return s.send(s.Writer.Info(fmt.Sprintf(format, a...)))
}
func run(command string, arguments ...string) error {
cmd := exec.Command(command, arguments...)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%q failed: %v, %s", command, err, out)
}
return nil
}