Add signal handler to example app
This commit is contained in:
parent
6452635485
commit
20acbfc8eb
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/localhots/satan"
|
||||
"github.com/localhots/satan/example/daemons"
|
||||
|
@ -40,6 +41,12 @@ func main() {
|
|||
defer s.StopDaemons()
|
||||
|
||||
sig := make(chan os.Signal)
|
||||
signal.Notify(sig, os.Interrupt)
|
||||
<-sig
|
||||
signal.Notify(sig, syscall.SIGINT, syscall.SIGHUP)
|
||||
switch <-sig {
|
||||
case syscall.SIGHUP:
|
||||
s.StopDaemons()
|
||||
s.StartDaemons()
|
||||
case syscall.SIGINT:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue