aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-09-13 21:25:51 -0700
committerChris Lu <chris.lu@gmail.com>2020-09-13 21:25:51 -0700
commit5d6753fb984c4ea4ee9e3b427cb468916d0b07fb (patch)
tree55317a3245f5202f83601f4dfbfe21dd711a7739 /weed/command
parent1af95c5b76d528ca8532e845305719818435df83 (diff)
downloadseaweedfs-5d6753fb984c4ea4ee9e3b427cb468916d0b07fb.tar.xz
seaweedfs-5d6753fb984c4ea4ee9e3b427cb468916d0b07fb.zip
shell: add volumeServer.leave command
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/volume.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 5ac31ba79..92f83f945 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -223,22 +223,27 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
// starting the cluster http server
clusterHttpServer := v.startClusterHttpService(volumeMux)
+ stopChan := make(chan bool)
grace.OnInterrupt(func() {
fmt.Println("volume server has be killed")
- // Stop heartbeatsZ
- glog.V(0).Infof("stop send heartbeat and wait %d seconds until shutdown ...", *v.preStopSeconds)
- volumeServer.SendHeartbeat = false
- time.Sleep(time.Duration(*v.preStopSeconds) * time.Second)
+ // Stop heartbeats
+ if !volumeServer.StopHeartbeat() {
+ glog.V(0).Infof("stop send heartbeat and wait %d seconds until shutdown ...", *v.preStopSeconds)
+ time.Sleep(time.Duration(*v.preStopSeconds) * time.Second)
+ }
- v.shutdown(publicHttpDown, clusterHttpServer, grpcS, volumeServer)
+ shutdown(publicHttpDown, clusterHttpServer, grpcS, volumeServer)
+ stopChan <- true
})
- select {}
+ select {
+ case <-stopChan:
+ }
}
-func (v VolumeServerOptions) shutdown(publicHttpDown httpdown.Server, clusterHttpServer httpdown.Server, grpcS *grpc.Server, volumeServer *weed_server.VolumeServer) {
+func shutdown(publicHttpDown httpdown.Server, clusterHttpServer httpdown.Server, grpcS *grpc.Server, volumeServer *weed_server.VolumeServer) {
// firstly, stop the public http service to prevent from receiving new user request
if nil != publicHttpDown {