From 2f447210867688539fc5c48eb7e1072a6167c927 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 28 Jun 2020 20:52:33 +0800 Subject: [PATCH] fix issue in reload feature in ghttp.Server --- .example/net/ghttp/server/reload/admin.go | 1 + net/ghttp/ghttp_server.go | 1 + net/ghttp/ghttp_server_admin_process.go | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.example/net/ghttp/server/reload/admin.go b/.example/net/ghttp/server/reload/admin.go index 1a965c02f..bb89a4b9d 100644 --- a/.example/net/ghttp/server/reload/admin.go +++ b/.example/net/ghttp/server/reload/admin.go @@ -7,6 +7,7 @@ import ( func main() { s := g.Server() s.EnableAdmin() + //s.BindHookHandler("/admin/*any", ghttp.HOOK_BEFORE_SERVE, func(r *ghttp.Request) { // if !r.BasicAuth("admin", "123", "") { // r.Exit() diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index cb567596a..3d7a6cdb1 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -183,6 +183,7 @@ func init() { // which is false in default. // // Note that this feature switch is not for single server instance but for whole process. +// Deprecated, use configuration of ghttp.Server for controlling this feature. func SetGraceful(enabled bool) { gracefulEnabled = enabled } diff --git a/net/ghttp/ghttp_server_admin_process.go b/net/ghttp/ghttp_server_admin_process.go index d9a2f8b70..663e76cef 100644 --- a/net/ghttp/ghttp_server_admin_process.go +++ b/net/ghttp/ghttp_server_admin_process.go @@ -10,6 +10,7 @@ import ( "bytes" "errors" "fmt" + "github.com/gogf/gf/text/gstr" "os" "runtime" "strings" @@ -112,7 +113,7 @@ func forkReloadProcess(newExeFilePath ...string) error { for fdk, fdv := range m { if len(fdv) > 0 { s := "" - for _, item := range strings.Split(fdv, ",") { + for _, item := range gstr.SplitAndTrim(fdv, ",") { array := strings.Split(item, "#") fd := uintptr(gconv.Uint(array[1])) if fd > 0 {