From 86bdeed4a2afba4f4f011133c605bd658fdda971 Mon Sep 17 00:00:00 2001 From: boyska Date: Sat, 10 Nov 2018 17:41:45 +0100 Subject: [PATCH] more signals handled --- cmd/circologd/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/circologd/main.go b/cmd/circologd/main.go index fa5142d..12faac1 100644 --- a/cmd/circologd/main.go +++ b/cmd/circologd/main.go @@ -3,10 +3,12 @@ package main import ( "flag" "fmt" + "log" "net" "net/http" "os" "os/signal" + "syscall" "git.lattuga.net/boyska/circolog" syslog "gopkg.in/mcuadros/go-syslog.v2" @@ -29,7 +31,7 @@ func main() { flag.Parse() interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt) + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) hub := circolog.NewHub(*bufsize) handler := syslog.NewChannelHandler(hub.LogMessages) @@ -85,7 +87,8 @@ func main() { for { select { - case <-interrupt: + case sig := <-interrupt: + log.Println("Quitting because of signal", sig) server.Kill() if err := httpServer.Close(); err != nil { fmt.Fprintln(os.Stderr, "Error closing http server:", err)