1
0
Fork 0

Add signal handler to example app

This commit is contained in:
Gregory Eremin 2016-01-10 14:53:55 +03:00
parent 6452635485
commit 20acbfc8eb
1 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"strings" "strings"
"syscall"
"github.com/localhots/satan" "github.com/localhots/satan"
"github.com/localhots/satan/example/daemons" "github.com/localhots/satan/example/daemons"
@ -40,6 +41,12 @@ func main() {
defer s.StopDaemons() defer s.StopDaemons()
sig := make(chan os.Signal) sig := make(chan os.Signal)
signal.Notify(sig, os.Interrupt) signal.Notify(sig, syscall.SIGINT, syscall.SIGHUP)
<-sig switch <-sig {
case syscall.SIGHUP:
s.StopDaemons()
s.StartDaemons()
case syscall.SIGINT:
return
}
} }