mirror of
https://github.com/safing/portbase
synced 2025-09-02 10:40:39 +00:00
Add force exiting
This commit is contained in:
parent
1cb93512f1
commit
1990465032
1 changed files with 9 additions and 1 deletions
10
run/main.go
10
run/main.go
|
@ -74,11 +74,19 @@ signalLoop:
|
||||||
fmt.Println(" <INTERRUPT>")
|
fmt.Println(" <INTERRUPT>")
|
||||||
log.Warning("main: program was interrupted, shutting down.")
|
log.Warning("main: program was interrupted, shutting down.")
|
||||||
|
|
||||||
|
forceCnt := 5
|
||||||
// catch signals during shutdown
|
// catch signals during shutdown
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
<-signalCh
|
<-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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue