Skip to content

Commit f234f09

Browse files
committed
catch journalctl exit
1 parent fe295f9 commit f234f09

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugin/input/journalctl/reader.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"os/exec"
99
"strings"
10+
"syscall"
1011

1112
"github.com/prometheus/client_golang/prometheus"
1213
"go.uber.org/zap"
@@ -94,10 +95,15 @@ func (r *journalReader) start() error {
9495
}
9596

9697
go r.readLines(out, r.config)
98+
go func() {
99+
if err := r.cmd.Wait(); err != nil {
100+
r.config.logger.Fatal("journalctl command exited with error", zap.Error(err))
101+
}
102+
}()
97103

98104
return nil
99105
}
100106

101107
func (r *journalReader) stop() error {
102-
return r.cmd.Process.Kill()
108+
return r.cmd.Process.Signal(syscall.SIGTERM)
103109
}

0 commit comments

Comments
 (0)