sigusr2 triggering buffer cleanup also via ctrlsock

This commit is contained in:
Blallo 2018-12-05 09:18:40 +01:00
parent b11c2edfc0
commit d61ab0638f
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

@ -32,7 +32,7 @@ func main() {
flag.Parse() flag.Parse()
interrupt := make(chan os.Signal, 1) 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) hub := circolog.NewHub(*bufsize)
handler := syslog.NewChannelHandler(hub.LogMessages) handler := syslog.NewChannelHandler(hub.LogMessages)
@ -115,6 +115,15 @@ func main() {
log.Println("paused") 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 { if sig == syscall.SIGTERM || sig == syscall.SIGINT {
log.Println("Quitting because of signal", sig) log.Println("Quitting because of signal", sig)
server.Kill() server.Kill()