SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
weed shell: simplify CLI option for filer
Chris Luf6a7e79dc370
diff --git a/weed/command/scaffold.go b/weed/command/scaffold.goindex f2832510cd..2aad29548a 100644--- a/weed/command/scaffold.go+++ b/weed/command/scaffold.go@@ -364,7 +364,8 @@ scripts = """sleep_minutes = 17 # sleep minutes between each script execution[master.filer]-default_filer_url = "http://localhost:8888/"+default = "localhost:8888" # used by maintenance scripts if the scripts needs to use fs related commands+[master.sequencer]type = "memory" # Choose [memory|etcd] type for storing the file id sequencediff --git a/weed/command/shell.go b/weed/command/shell.goindex dcf70608ff..6dd768f47b 100644--- a/weed/command/shell.go+++ b/weed/command/shell.go@@ -9,14 +9,14 @@ import ()var (- shellOptions shell.ShellOptions- shellInitialFilerUrl *string+ shellOptions shell.ShellOptions+ shellInitialFiler *string)func init() {cmdShell.Run = runShell // break init cycleshellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")- shellInitialFilerUrl = cmdShell.Flag.String("filer.url", "http://localhost:8888/", "initial filer url")+ shellInitialFiler = cmdShell.Flag.String("filer", "localhost:8888", "filer host and port")}var cmdShell = &Command{@@ -32,12 +32,13 @@ func runShell(command *Command, args []string) bool {util.LoadConfiguration("security", false)shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")- var filerPwdErr error- shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, filerPwdErr = util.ParseFilerUrl(*shellInitialFilerUrl)- if filerPwdErr != nil {- fmt.Printf("failed to parse url filer.url=%s : %v\n", *shellInitialFilerUrl, filerPwdErr)+ var err error+ shellOptions.FilerHost, shellOptions.FilerPort, err = util.ParseHostPort(*shellInitialFiler)+ if err != nil {+ fmt.Printf("failed to parse filer %s: %v\n", *shellInitialFiler, err)return false}+ shellOptions.Directory = "/"shell.RunShell(shellOptions)diff --git a/weed/server/master_server.go b/weed/server/master_server.goindex 497990f29a..4a264d4325 100644--- a/weed/server/master_server.go+++ b/weed/server/master_server.go@@ -197,8 +197,8 @@ func (ms *MasterServer) startAdminScripts() {v.SetDefault("master.maintenance.sleep_minutes", 17)sleepMinutes := v.GetInt("master.maintenance.sleep_minutes")- v.SetDefault("master.filer.default_filer_url", "http://localhost:8888/")- filerURL := v.GetString("master.filer.default_filer_url")+ v.SetDefault("master.filer.default", "localhost:8888")+ filerHostPort := v.GetString("master.filer.default")scriptLines := strings.Split(adminScripts, "\n")@@ -208,9 +208,10 @@ func (ms *MasterServer) startAdminScripts() {shellOptions.GrpcDialOption = security.LoadClientTLS(v, "grpc.master")shellOptions.Masters = &masterAddress- shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, err = util.ParseFilerUrl(filerURL)+ shellOptions.FilerHost, shellOptions.FilerPort, err = util.ParseHostPort(filerHostPort)+ shellOptions.Directory = "/"if err != nil {- glog.V(0).Infof("failed to parse master.filer.default_filer_urll=%s : %v\n", filerURL, err)+ glog.V(0).Infof("failed to parse master.filer.default = %s : %v\n", filerHostPort, err)return}diff --git a/weed/util/parse.go b/weed/util/parse.goindex 6593d43b6b..0955db6824 100644--- a/weed/util/parse.go+++ b/weed/util/parse.go@@ -1,6 +1,7 @@package utilimport (+ "fmt""net/url""strconv""strings"@@ -45,3 +46,18 @@ func ParseFilerUrl(entryPath string) (filerServer string, filerPort int64, pathpath = u.Pathreturn}++func ParseHostPort(hostPort string) (filerServer string, filerPort int64, err error) {+ parts := strings.Split(hostPort, ":")+ if len(parts) != 2 {+ err = fmt.Errorf("failed to parse %s\n", hostPort)+ return+ }++ filerPort, err = strconv.ParseInt(parts[1], 10, 64)+ if err == nil {+ filerServer = parts[0]+ }++ return+}