diff --git a/frame/g/g_func.go b/frame/g/g_func.go index e29fbf94a..64b284482 100644 --- a/frame/g/g_func.go +++ b/frame/g/g_func.go @@ -19,11 +19,16 @@ func NewVar(i interface{}, safe ...bool) *Var { return gvar.New(i, safe...) } -// Wait blocks until: -// 1. All the web servers shutdown, it does nothing if there's no running web server. -// 2. Shutdown signals received and all registered shutdown handlers done. +// Wait is an alias of ghttp.Wait, which blocks until all the web servers shutdown. +// It's commonly used in multiple servers situation. func Wait() { ghttp.Wait() +} + +// Listen is an alias of gproc.Listen, which handles the signals received and automatically +// calls registered signal handler functions. +// It blocks until shutdown signals received and all registered shutdown handlers done. +func Listen() { gproc.Listen() } diff --git a/os/gproc/gproc_signal.go b/os/gproc/gproc_signal.go index 8d9231f04..40ad5464b 100644 --- a/os/gproc/gproc_signal.go +++ b/os/gproc/gproc_signal.go @@ -7,6 +7,7 @@ package gproc import ( + "github.com/gogf/gf/internal/intlog" "os" "os/signal" "sync" @@ -64,6 +65,7 @@ func Listen() { for { wg := sync.WaitGroup{} sig = <-sigChan + intlog.Printf(`signal received: %s`, sig.String()) if handlers, ok := signalHandlerMap[sig]; ok { for _, handler := range handlers { wg.Add(1)