diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-10-06 21:30:30 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-06 09:30:30 -0700 |
| commit | b9933d558973c41ff05f50a509533d1045bae44f (patch) | |
| tree | 28a4f9434c809d753c687cf3130b4a954462ef09 /weed/command | |
| parent | 36daa7709d52e368ee4efc9a05a4e9dece321dc0 (diff) | |
| download | seaweedfs-b9933d558973c41ff05f50a509533d1045bae44f.tar.xz seaweedfs-b9933d558973c41ff05f50a509533d1045bae44f.zip | |
master server graceful stop (#3797)
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/master.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index f20b2dc62..a74389b1f 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -2,6 +2,7 @@ package command import ( "fmt" + hashicorpRaft "github.com/hashicorp/raft" "net/http" "os" "path" @@ -253,6 +254,13 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { go httpS.Serve(masterListener) } + grace.OnInterrupt(ms.Shutdown) + grace.OnInterrupt(grpcS.GracefulStop) + grace.OnReload(func() { + if ms.Topo.HashicorpRaft != nil && ms.Topo.HashicorpRaft.State() == hashicorpRaft.Leader { + ms.Topo.HashicorpRaft.LeadershipTransfer() + } + }) select {} } |
