mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Merge pull request #56 from safing/feature/force-exiting
Add force exiting
This commit is contained in:
commit
ebfb744fbc
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>")
|
||||
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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue