Updated SIG* handling code in main().
This commit is contained in:
parent
3251d9e983
commit
62f6e3b976
@ -99,20 +99,17 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
reloadSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(reloadSignal, syscall.SIGHUP)
|
||||
sysSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(sysSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV, syscall.SIGHUP)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
<-reloadSignal
|
||||
for {
|
||||
switch <-sysSignal {
|
||||
case os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV:
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
if err := plylst.Reload(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
doneSignal := make(chan os.Signal, 1)
|
||||
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV)
|
||||
|
||||
<-doneSignal
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user