fix issue: Windows Platform did not handle process signal (#3154)

This commit is contained in:
zhangyuyu
2023-11-14 20:00:26 +08:00
committed by GitHub
parent 4d7f9552fe
commit 84ed66018e

View File

@ -9,7 +9,19 @@
package ghttp
// registerSignalHandler does nothing on window platform.
func handleProcessSignal() {
import (
"context"
"os"
"github.com/gogf/gf/v2/os/gproc"
)
// handleProcessSignal handles all signals from system in blocking way.
func handleProcessSignal() {
var ctx = context.TODO()
gproc.AddSigHandlerShutdown(func(sig os.Signal) {
shutdownWebServersGracefully(ctx, sig)
})
gproc.Listen()
}