|
|
@ -11,6 +11,7 @@ import (
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/core/threading"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
@ -46,10 +47,10 @@ func gracefulStop(signals chan os.Signal) {
|
|
|
|
signal.Stop(signals)
|
|
|
|
signal.Stop(signals)
|
|
|
|
|
|
|
|
|
|
|
|
logx.Info("Got signal SIGTERM, shutting down...")
|
|
|
|
logx.Info("Got signal SIGTERM, shutting down...")
|
|
|
|
wrapUpListeners.notifyListeners()
|
|
|
|
go wrapUpListeners.notifyListeners()
|
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(wrapUpTime)
|
|
|
|
time.Sleep(wrapUpTime)
|
|
|
|
shutdownListeners.notifyListeners()
|
|
|
|
go shutdownListeners.notifyListeners()
|
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(delayTimeBeforeForceQuit - wrapUpTime)
|
|
|
|
time.Sleep(delayTimeBeforeForceQuit - wrapUpTime)
|
|
|
|
logx.Infof("Still alive after %v, going to force kill the process...", delayTimeBeforeForceQuit)
|
|
|
|
logx.Infof("Still alive after %v, going to force kill the process...", delayTimeBeforeForceQuit)
|
|
|
@ -81,7 +82,9 @@ func (lm *listenerManager) notifyListeners() {
|
|
|
|
lm.lock.Lock()
|
|
|
|
lm.lock.Lock()
|
|
|
|
defer lm.lock.Unlock()
|
|
|
|
defer lm.lock.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
group := threading.NewRoutineGroup()
|
|
|
|
for _, listener := range lm.listeners {
|
|
|
|
for _, listener := range lm.listeners {
|
|
|
|
listener()
|
|
|
|
group.RunSafe(listener)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
group.Wait()
|
|
|
|
}
|
|
|
|
}
|
|
|
|