Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/util/signals/unix.go

48 lignes
731 o
Go
Brut Vue normale Historique

2017-05-07 14:07:20 +02:00
// +build !win32
package signals
import (
2017-05-17 07:58:40 +02:00
"github.com/NyaaPantsu/nyaa/router"
"github.com/NyaaPantsu/nyaa/util/log"
2017-05-07 14:07:20 +02:00
"os"
"os/signal"
"syscall"
)
func handleReload() {
log.Info("Got SIGHUP")
router.ReloadTemplates()
log.Info("reloaded templates")
}
// Handle signals
// returns when done
func Handle() {
chnl := make(chan os.Signal)
signal.Notify(chnl, syscall.SIGHUP, os.Interrupt)
2017-05-07 14:07:20 +02:00
for {
sig, ok := <-chnl
if !ok {
break
}
switch sig {
case syscall.SIGHUP:
handleReload()
break
case os.Interrupt:
interrupted()
return
2017-05-07 14:07:20 +02:00
default:
break
}
}
}
// unix implementation of interrupt
// called in interrupted()
func handleInterrupt() {
// XXX: put unix specific cleanup here as needed
}