mirror of
https://github.com/kardianos/service.git
synced 2025-10-05 16:56:54 +08:00
service: return better error messages from executed commands.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user