Skip to content

Commit

Permalink
add log when the command execution failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Jun 7, 2015
1 parent abcc489 commit dfafa32
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"

"github.com/Songmu/timeout"
"github.com/mackerelio/mackerel-agent/logging"
)

var utilLogger = logging.GetLogger("util")

// timeoutDuration is option of `Runcommand()` set timeout limit of command execution.
var timeoutDuration = 30 * time.Second

Expand All @@ -28,6 +31,8 @@ func RunCommand(command string) (string, string, int, error) {
if err == nil && exitStatus.IsTimedOut() {
err = fmt.Errorf("command timed out")
}

if err != nil {
utilLogger.Errorf("RunCommand error command: %s, error: %s", command, err)
}
return stdout, stderr, exitStatus.GetChildExitCode(), err
}

0 comments on commit dfafa32

Please sign in to comment.