Add force exiting

This commit is contained in:
Daniel 2020-06-05 13:07:27 +02:00
parent 1cb93512f1
commit 1990465032

View file

@ -74,11 +74,19 @@ signalLoop:
fmt.Println(" <INTERRUPT>")
log.Warning("main: program was interrupted, shutting down.")
forceCnt := 5
// catch signals during shutdown
go func() {
for {
<-signalCh
fmt.Println(" <INTERRUPT> again, but already shutting down")
forceCnt--
if forceCnt > 0 {
fmt.Printf(" <INTERRUPT> again, but already shutting down. %d more to force.\n", forceCnt)
} else {
fmt.Fprintln(os.Stderr, "===== FORCED EXIT =====")
printStackTo(os.Stderr)
os.Exit(1)
}
}
}()