diff --git a/example/runner/runner.go b/example/runner/runner.go index 46efe84..984c56d 100644 --- a/example/runner/runner.go +++ b/example/runner/runner.go @@ -25,6 +25,8 @@ type Config struct { Exec string Args []string Env []string + + Stderr, Stdout string } var logger service.Logger @@ -61,13 +63,29 @@ func (p *program) run(cmd *exec.Cmd) { } }() - out, err := cmd.CombinedOutput() + if p.Stderr != "" { + f, err := os.OpenFile(p.Stderr, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0777) + if err != nil { + logger.Warningf("Failed to open std err %q: %v", p.Stderr, err) + return + } + defer f.Close() + cmd.Stderr = f + } + if p.Stdout != "" { + f, err := os.OpenFile(p.Stdout, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0777) + if err != nil { + logger.Warningf("Failed to open std out %q: %v", p.Stdout, err) + return + } + defer f.Close() + cmd.Stdout = f + } + + err := cmd.Run() if err != nil { logger.Warningf("Error running: %v", err) } - if len(out) != 0 { - logger.Info(string(out)) - } return } diff --git a/example/runner/runner.json b/example/runner/runner.json index ed1bbaf..4afec9d 100644 --- a/example/runner/runner.json +++ b/example/runner/runner.json @@ -11,5 +11,8 @@ "GOROOT_BOOTSTRAP=C:\\dev\\go_ready", "HOMEDRIVE=C:", "HOMEPATH=\\Documents and Settings\\Administrator" - ] + ], + + "Stderr": "C:\\builder_err.log", + "Stdout": "C:\\builder_out.log" } \ No newline at end of file