sigusr2 triggering buffer cleanup also via ctrlsock
This commit is contained in:
parent
b11c2edfc0
commit
d61ab0638f
1 changed files with 10 additions and 1 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue