shim improvements for docs, clean quit, and slow readers (#7452)
This commit is contained in:
23
plugins/inputs/execd/shim/goshim_posix.go
Normal file
23
plugins/inputs/execd/shim/goshim_posix.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// +build !windows
|
||||
|
||||
package shim
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func listenForCollectMetricsSignals(ctx context.Context, collectMetricsPrompt chan os.Signal) {
|
||||
// just listen to all the signals.
|
||||
signal.Notify(collectMetricsPrompt, syscall.SIGHUP, syscall.SIGUSR1, syscall.SIGUSR2)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// context done. stop to signals to avoid pushing messages to a closed channel
|
||||
signal.Stop(collectMetricsPrompt)
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user