1
0

Updated SIG* handling code in main().

This commit is contained in:
Alexander Andreev 2023-10-06 04:58:58 +04:00
parent 3251d9e983
commit 62f6e3b976
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -99,20 +99,17 @@ func main() {
} }
}() }()
reloadSignal := make(chan os.Signal, 1) sysSignal := make(chan os.Signal, 1)
signal.Notify(reloadSignal, syscall.SIGHUP) signal.Notify(sysSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV, syscall.SIGHUP)
go func() { for {
for { switch <-sysSignal {
<-reloadSignal case os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV:
return
case syscall.SIGHUP:
if err := plylst.Reload(); err != nil { if err := plylst.Reload(); err != nil {
log.Println(err) log.Println(err)
} }
} }
}() }
doneSignal := make(chan os.Signal, 1)
signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGABRT, syscall.SIGSEGV)
<-doneSignal
} }