diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-10-11 00:04:31 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-10-11 00:04:31 -0700 |
| commit | da6154b29c71c5f12d482ffd773e77d492b89371 (patch) | |
| tree | 865a80e6256fa7893bcdae80e9ea2412a145b609 /weed/command/volume.go | |
| parent | 60d2f1557d4b871fb8b19cab8206d7b725c12845 (diff) | |
| download | seaweedfs-da6154b29c71c5f12d482ffd773e77d492b89371.tar.xz seaweedfs-da6154b29c71c5f12d482ffd773e77d492b89371.zip | |
refactor volume server to startVolumeServer()
Diffstat (limited to 'weed/command/volume.go')
| -rw-r--r-- | weed/command/volume.go | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go index 407c39eb1..df8d842dc 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -1,17 +1,17 @@ package command import ( - "net/http" "os" "runtime" "strconv" "strings" - "time" - "github.com/chrislusf/seaweedfs/weed/glog" - "github.com/chrislusf/seaweedfs/weed/server" - "github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/util" + "net/http" + "github.com/chrislusf/seaweedfs/weed/storage" + "github.com/chrislusf/seaweedfs/weed/server" + "time" + "runtime/pprof" ) var ( @@ -81,9 +81,16 @@ func runVolume(cmd *Command, args []string) bool { runtime.GOMAXPROCS(*v.maxCpu) util.SetupProfiling(*v.cpuProfile, *v.memProfile) + v.startVolumeServer(*volumeFolders, *maxVolumeCounts, *volumeWhiteListOption) + + return true +} + +func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, volumeWhiteListOption string) { + //Set multiple folders and each folder's max volume count limit' - v.folders = strings.Split(*volumeFolders, ",") - maxCountStrings := strings.Split(*maxVolumeCounts, ",") + v.folders = strings.Split(volumeFolders, ",") + maxCountStrings := strings.Split(maxVolumeCounts, ",") for _, maxString := range maxCountStrings { if max, e := strconv.Atoi(maxString); e == nil { v.folderMaxLimits = append(v.folderMaxLimits, max) @@ -101,8 +108,8 @@ func runVolume(cmd *Command, args []string) bool { } //security related white list configuration - if *volumeWhiteListOption != "" { - v.whiteList = strings.Split(*volumeWhiteListOption, ",") + if volumeWhiteListOption != "" { + v.whiteList = strings.Split(volumeWhiteListOption, ",") } if *v.ip == "" { @@ -166,10 +173,11 @@ func runVolume(cmd *Command, args []string) bool { util.OnInterrupt(func() { volumeServer.Shutdown() + pprof.StopCPUProfile() }) if e := http.Serve(listener, volumeMux); e != nil { glog.Fatalf("Volume server fail to serve: %v", e) } - return true + } |
