Skip to content

Commit

Permalink
optimize the handling of the SIGUSR1 signal (gogf#2532)
Browse files Browse the repository at this point in the history
optimize the handling of the SIGUSR1 signal
  • Loading branch information
windvalley authored Mar 21, 2023
1 parent 0b6798a commit 3a8fc1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/ghttp/ghttp_server_admin_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3a8fc1e

Please sign in to comment.