This commit is contained in:
crusader 2017-12-18 17:55:05 +09:00
parent df6b39b641
commit 514a2b348c

21
main.go
View File

@ -2,7 +2,6 @@ package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
@ -26,9 +25,6 @@ func main() {
s := server.New(*pidPath)
stop := make(chan os.Signal)
signal.Notify(stop, syscall.SIGINT)
go func() {
if err := s.Start(); nil != err {
log.Printf("Server: Start error %v", err)
@ -36,10 +32,19 @@ func main() {
}
}()
select {
case signal := <-stop:
fmt.Printf("Got signal: %v\n", signal)
}
// // Set up channel on which to send signal notifications.
// // We must use a buffered channel or risk missing the signal
// // if we're not ready to receive when the signal is sent.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt,
syscall.SIGKILL,
syscall.SIGSTOP,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
<-interrupt
s.Stop()