Skip to content

Commit

Permalink
catch journalctl exit
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryRomanov committed Feb 5, 2025
1 parent fe295f9 commit f234f09
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin/input/journalctl/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os/exec"
"strings"
"syscall"

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

go r.readLines(out, r.config)
go func() {
if err := r.cmd.Wait(); err != nil {
r.config.logger.Fatal("journalctl command exited with error", zap.Error(err))
}
}()

return nil
}

func (r *journalReader) stop() error {
return r.cmd.Process.Kill()
return r.cmd.Process.Signal(syscall.SIGTERM)
}

0 comments on commit f234f09

Please sign in to comment.