Add signal handler to example app
This commit is contained in:
+9
-2
@@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user