From d61ab0638fb29591e0aaa3125757332320d5b43d Mon Sep 17 00:00:00 2001 From: Blallo Date: Wed, 5 Dec 2018 09:18:40 +0100 Subject: [PATCH] sigusr2 triggering buffer cleanup also via ctrlsock --- cmd/circologd/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/circologd/main.go b/cmd/circologd/main.go index b40641c..4d73150 100644 --- a/cmd/circologd/main.go +++ b/cmd/circologd/main.go @@ -32,7 +32,7 @@ func main() { flag.Parse() interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, syscall.SIGINT, syscall.SIGUSR1, syscall.SIGTERM) + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGTERM) hub := circolog.NewHub(*bufsize) handler := syslog.NewChannelHandler(hub.LogMessages) @@ -115,6 +115,15 @@ func main() { log.Println("paused") } } + if sig == syscall.SIGUSR2 { + hub.Commands <- circolog.HubFullCommand{Command: circolog.CommandClear} + resp := <-hub.Responses + if resp.Value.(bool) { + log.Println("buffer cleaned") + } else { + log.Println("buffer NOT cleaned") + } + } if sig == syscall.SIGTERM || sig == syscall.SIGINT { log.Println("Quitting because of signal", sig) server.Kill()