optimize the handling of the SIGUSR1 signal (#2532)

optimize the handling of the SIGUSR1 signal
This commit is contained in:
XG
2023-03-21 21:26:49 +08:00
committed by GitHub
parent 0b6798acb5
commit 3a8fc1e70d

View File

@ -16,6 +16,7 @@ import (
"syscall"
"github.com/gogf/gf/v2/internal/intlog"
"github.com/gogf/gf/v2/os/glog"
)
// procSignalChan is the channel for listening to the signal.
@ -54,6 +55,13 @@ func handleProcessSignal() {
// Restart the servers.
case syscall.SIGUSR1:
// If the graceful restart feature is not enabled,
// it does nothing except printing a warning log.
if !gracefulEnabled {
glog.Warning(ctx, "graceful reload feature is disabled")
continue
}
if err := restartWebServers(ctx, sig.String()); err != nil {
intlog.Errorf(ctx, `%+v`, err)
}