add signal handler

master
dingjun 6 years ago
parent 10850b7f92
commit 96e0332d16

@ -6,7 +6,10 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net" "net"
"os"
"os/signal"
"strings" "strings"
"syscall"
glog "github.com/fangdingjun/go-log" glog "github.com/fangdingjun/go-log"
proxyproto "github.com/pires/go-proxyproto" proxyproto "github.com/pires/go-proxyproto"
@ -202,5 +205,11 @@ func main() {
} }
}(l) }(l)
} }
select {}
ch := make(chan os.Signal, 2)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
select {
case s := <-ch:
glog.Printf("received signal %s, exit.", s)
}
} }

Loading…
Cancel
Save