From a683156ccbd909fc8bd122b8a843bb18304bb909 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 14 Nov 2023 15:47:00 +0800 Subject: [PATCH 1/2] fix issue: Windows Platform did not handle process signal --- net/ghttp/ghttp_server_admin_windows.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_server_admin_windows.go b/net/ghttp/ghttp_server_admin_windows.go index 135dc56d5f5..14d5e8612cb 100644 --- a/net/ghttp/ghttp_server_admin_windows.go +++ b/net/ghttp/ghttp_server_admin_windows.go @@ -9,7 +9,17 @@ package ghttp -// registerSignalHandler does nothing on window platform. +import ( + "github.com/gogf/gf/v2/os/gproc" + "os" +) + +// 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() } From ad0ffa4d9899c80dcc469b33e2fac40fac4211f8 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 14 Nov 2023 18:05:59 +0800 Subject: [PATCH 2/2] fix issue: Windows Platform did not handle process signal --- net/ghttp/ghttp_server_admin_windows.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_server_admin_windows.go b/net/ghttp/ghttp_server_admin_windows.go index 14d5e8612cb..7d83e3e0da9 100644 --- a/net/ghttp/ghttp_server_admin_windows.go +++ b/net/ghttp/ghttp_server_admin_windows.go @@ -10,8 +10,10 @@ package ghttp import ( - "github.com/gogf/gf/v2/os/gproc" + "context" "os" + + "github.com/gogf/gf/v2/os/gproc" ) // handleProcessSignal handles all signals from system in blocking way.