|
@ -11,11 +11,13 @@ import ( |
|
|
func OnInterrupt(fn func()) { |
|
|
func OnInterrupt(fn func()) { |
|
|
// deal with control+c,etc
|
|
|
// deal with control+c,etc
|
|
|
signalChan := make(chan os.Signal, 1) |
|
|
signalChan := make(chan os.Signal, 1) |
|
|
|
|
|
// controlling terminal close, daemon not exit
|
|
|
|
|
|
signal.Ignore(syscall.SIGHUP) |
|
|
signal.Notify(signalChan, |
|
|
signal.Notify(signalChan, |
|
|
os.Interrupt, |
|
|
os.Interrupt, |
|
|
os.Kill, |
|
|
os.Kill, |
|
|
syscall.SIGALRM, |
|
|
syscall.SIGALRM, |
|
|
syscall.SIGHUP, |
|
|
|
|
|
|
|
|
// syscall.SIGHUP,
|
|
|
syscall.SIGINT, |
|
|
syscall.SIGINT, |
|
|
syscall.SIGTERM, |
|
|
syscall.SIGTERM, |
|
|
syscall.SIGQUIT) |
|
|
syscall.SIGQUIT) |
|
|