master server graceful stop (#3797)

This commit is contained in:
Konstantin Lebedev authored and GitHub committed 2022-10-06 09:30:30 -07:00
1 parent 36daa7709d
commit b9933d5589
3 files changed
+37 -14

No files matched your search

+8
View File
@@ -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 {}
}