diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-08-26 16:16:11 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2020-08-26 16:16:11 +0500 |
| commit | 464d4c82ecb0aaaf58d9565cd7b7c9f28311c1e4 (patch) | |
| tree | a59a8160a7bf25412be6221c3807722e356b306a /weed/command/volume.go | |
| parent | 1901f15cd2dc706a7d614dd2fc2c654e31883399 (diff) | |
| download | seaweedfs-464d4c82ecb0aaaf58d9565cd7b7c9f28311c1e4.tar.xz seaweedfs-464d4c82ecb0aaaf58d9565cd7b7c9f28311c1e4.zip | |
stop send heartbeat before stop volume server
Diffstat (limited to 'weed/command/volume.go')
| -rw-r--r-- | weed/command/volume.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go index 6fb7447e7..5a0dc9e67 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -55,6 +55,7 @@ type VolumeServerOptions struct { fileSizeLimitMB *int minFreeSpacePercents []float32 pprof *bool + preStopSeconds *int // pulseSeconds *int } @@ -66,6 +67,7 @@ func init() { v.publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible address") v.bindIp = cmdVolume.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to") v.masters = cmdVolume.Flag.String("mserver", "localhost:9333", "comma-separated master servers") + v.preStopSeconds = cmdVolume.Flag.Int("preStopSeconds", 30, "number of seconds between stop send heartbeats and stop volume server") // v.pulseSeconds = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than or equal to the master's setting") v.idleConnectionTimeout = cmdVolume.Flag.Int("idleTimeout", 30, "connection idle seconds") v.dataCenter = cmdVolume.Flag.String("dataCenter", "", "current volume server's data center name") @@ -206,7 +208,6 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v *v.compactionMBPerSecond, *v.fileSizeLimitMB, ) - // starting grpc server grpcS := v.startGrpcService(volumeServer) @@ -227,6 +228,11 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v fmt.Println("volume server has be killed") var startTime time.Time + // Stop heartbeats + fmt.Println("stop send heartbeat and sleep %d sec", v.preStopSeconds) + volumeServer.SendHeartbeat = false + time.Sleep(time.Duration(*v.preStopSeconds) * time.Second) + fmt.Println("end sleep 20 sec") // firstly, stop the public http service to prevent from receiving new user request if nil != publicHttpDown { startTime = time.Now() |
