mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
34 lines
619 B
Go
34 lines
619 B
Go
//go:build windows
|
|
|
|
package debug
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"os/signal"
|
|
|
|
_debug "github.com/ledgerwatch/erigon/common/debug"
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
func ListenSignals(stack io.Closer) {
|
|
sigc := make(chan os.Signal, 1)
|
|
signal.Notify(sigc, os.Interrupt)
|
|
_debug.GetSigC(&sigc)
|
|
defer signal.Stop(sigc)
|
|
|
|
<-sigc
|
|
log.Info("Got interrupt, shutting down...")
|
|
if stack != nil {
|
|
go stack.Close()
|
|
}
|
|
for i := 10; i > 0; i-- {
|
|
<-sigc
|
|
if i > 1 {
|
|
log.Warn("Already shutting down, interrupt more to panic.", "times", i-1)
|
|
}
|
|
}
|
|
Exit() // ensure trace and CPU profile data is flushed.
|
|
LoudPanic("boom")
|
|
}
|