diff --git a/examples/timestamps.d/timestamps.hcl b/examples/timestamps.d/timestamps.hcl index cb98ae1..ad4fd6b 100644 --- a/examples/timestamps.d/timestamps.hcl +++ b/examples/timestamps.d/timestamps.hcl @@ -6,6 +6,6 @@ job "echoloop" { ] stdout = "test.log" - stdout = "test_error.log" + stderr = "test_error.log" enableTimestamps = true } \ No newline at end of file diff --git a/pkg/proc/basejob.go b/pkg/proc/basejob.go index ad8a09a..642add1 100644 --- a/pkg/proc/basejob.go +++ b/pkg/proc/basejob.go @@ -121,11 +121,13 @@ func (job *baseJob) startOnce(ctx context.Context, process chan<- *os.Process) e if err != nil { return fmt.Errorf("failed to create stdout pipe for process: %s", err.Error()) } + defer stdoutPipe.Close() - stderrPipe, _ := cmd.StderrPipe() + stderrPipe, err := cmd.StderrPipe() if err != nil { return fmt.Errorf("failed to create stderr pipe for process: %s", err.Error()) } + defer stderrPipe.Close() go job.logWithTimestamp(stdoutPipe, job.stdout) go job.logWithTimestamp(stderrPipe, job.stderr)