diff --git a/weed/command/filer.go b/weed/command/filer.go index 8db4f8c85..3cc69ccf2 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -483,8 +483,9 @@ func (fo *FilerOptions) startFiler() { } httpS := newHttpServer(defaultMux, tlsConfig) if MiniClusterCtx != nil { + ctx := MiniClusterCtx go func() { - <-MiniClusterCtx.Done() + <-ctx.Done() httpS.Shutdown(context.Background()) grpcS.Stop() }() @@ -502,8 +503,9 @@ func (fo *FilerOptions) startFiler() { } httpS := newHttpServer(defaultMux, nil) if MiniClusterCtx != nil { + ctx := MiniClusterCtx go func() { - <-MiniClusterCtx.Done() + <-ctx.Done() httpS.Shutdown(context.Background()) grpcS.Stop() }() diff --git a/weed/command/master.go b/weed/command/master.go index 2ed59ce65..2a7511fbf 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -311,8 +311,9 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { ms.Topo.HashicorpRaft.LeadershipTransfer() } }) - if MiniClusterCtx != nil { - <-MiniClusterCtx.Done() + ctx := MiniClusterCtx + if ctx != nil { + <-ctx.Done() ms.Shutdown() grpcS.Stop() } else { diff --git a/weed/command/s3.go b/weed/command/s3.go index db62e6e1c..625faa14e 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -408,8 +408,9 @@ func (s3opt *S3Options) startS3Server() bool { } httpS := newHttpServer(router, tlsConfig) if MiniClusterCtx != nil { + ctx := MiniClusterCtx go func() { - <-MiniClusterCtx.Done() + <-ctx.Done() httpS.Shutdown(context.Background()) grpcS.Stop() }() diff --git a/weed/command/volume.go b/weed/command/volume.go index 4e6311c9d..601849f28 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -319,10 +319,11 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v stopChan <- true }) - if MiniClusterCtx != nil { + ctx := MiniClusterCtx + if ctx != nil { select { case <-stopChan: - case <-MiniClusterCtx.Done(): + case <-ctx.Done(): shutdown(publicHttpDown, clusterHttpServer, grpcS, volumeServer) } } else {