@cryptotaxi247 / netdata-1 / commits / 04ab0c52d

fix(go.d): ignore sigpipe to exit gracefully (#19739)

ignore sigpipe

Ilya Mashchenko committed Mar 2, 2025 at 16:26 UTC 04ab0c52d24788898a5cd0fa98086e2ec3d51b55
1 file changed +3 -2
src/go/plugin/go.d/agent/agent.go
+3 -2
@@ -94,6 +94,8 @@ func (a *Agent) Run() {
94 func serve(a *Agent) {
95 ch := make(chan os.Signal, 1)
96 signal.Notify(ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
97 + signal.Ignore(syscall.SIGPIPE)
98 +
99 var wg sync.WaitGroup
100
101 var exit bool
@@ -228,12 +230,11 @@ func (a *Agent) keepAlive() {
230 var n int
231 for range tk.C {
232 if err := a.api.EMPTYLINE(); err != nil {
231 - a.Infof("keepAlive: %v", err)
233 n++
234 } else {
235 n = 0
236 }
236 - if n == 3 {
237 + if n >= 30 {
238 a.Info("too many keepAlive errors. Terminating...")
239 os.Exit(0)
240 }