mini clean shutdown

This commit is contained in:
Chris Lu committed 2026-02-19 20:45:41 -08:00
1 parent e9e7b29d2f
commit 9e17f6baff
10 files changed
+54 -27

No files matched your search

+6 -1
View File
@@ -341,7 +341,12 @@ func (fo *FilerOptions) startFiler() {
glog.V(0).Infof("Initialized credential manager: %s", credentialManager.GetStoreName())
}
fs, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, &weed_server.FilerOption{
// ... some code omitted for simplicity ...
fctx := MiniClusterCtx
if fctx == nil {
fctx = context.Background()
}
fs, nfs_err := weed_server.NewFilerServer(fctx, defaultMux, publicVolumeMux, &weed_server.FilerOption{
Masters: fo.masters,
FilerGroup: *fo.filerGroup,
Collection: *fo.collection,
+5 -1
View File
@@ -268,7 +268,11 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
}()
}
go ms.MasterClient.KeepConnectedToMaster(context.Background())
masterCtx := MiniClusterCtx
if masterCtx == nil {
masterCtx = context.Background()
}
go ms.MasterClient.KeepConnectedToMaster(masterCtx)
// start http server
var (
+7
View File
@@ -1107,6 +1107,13 @@ func startMiniAdminWithWorker(allServicesReady chan struct{}) {
// Wait for worker to be ready by polling its gRPC port
workerGrpcAddr := fmt.Sprintf("%s:%d", bindIp, *miniAdminOptions.grpcPort)
waitForWorkerReady(workerGrpcAddr)
if ctx != nil {
go func() {
<-ctx.Done()
glog.V(0).Infof("Cluster context cancelled, initiating aggressive shutdown of mini services...")
}()
}
}
// waitForAdminServerReady pings the admin server HTTP endpoint to check if it's ready
+5 -1
View File
@@ -288,7 +288,11 @@ func (s3opt *S3Options) startS3Server() bool {
*s3opt.bindIp = "0.0.0.0"
}
s3ApiServer, s3ApiServer_err = s3api.NewS3ApiServer(router, &s3api.S3ApiServerOption{
s3ctx := MiniClusterCtx
if s3ctx == nil {
s3ctx = context.Background()
}
s3ApiServer, s3ApiServer_err = s3api.NewS3ApiServer(s3ctx, router, &s3api.S3ApiServerOption{
Filers: filerAddresses,
Masters: masterAddresses,
Port: *s3opt.port,
+8 -3
View File
@@ -1,6 +1,7 @@
package command
import (
"context"
"fmt"
"net/http"
httppprof "net/http/pprof"
@@ -267,7 +268,11 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
// Determine volume server ID: if not specified, use ip:port
volumeServerId := util.GetVolumeServerId(*v.id, *v.ip, *v.port)
volumeServer := weed_server.NewVolumeServer(volumeMux, publicVolumeMux,
vctx := MiniClusterCtx
if vctx == nil {
vctx = context.Background()
}
volumeServer := weed_server.NewVolumeServer(vctx, volumeMux, publicVolumeMux,
*v.ip, *v.port, *v.portGrpc, *v.publicUrl, volumeServerId,
v.folders, v.folderMaxLimits, minFreeSpaces, diskTypes,
*v.idxFolder,
@@ -349,8 +354,8 @@ func shutdown(publicHttpDown httpdown.Server, clusterHttpServer httpdown.Server,
glog.Warningf("stop the cluster http server failed, %v", err)
}
glog.V(0).Infof("graceful stop gRPC ...")
grpcS.GracefulStop()
glog.V(0).Infof("stop gRPC ...")
grpcS.Stop()
volumeServer.Shutdown()