aboutsummaryrefslogtreecommitdiff
path: root/weed/command/shell.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-10-25 07:44:37 -0700
committerChris Lu <chris.lu@gmail.com>2019-10-25 07:44:37 -0700
commit288c45a690e26c6e0d4b55b50ffb089e0c544c59 (patch)
tree4c98dbee8703c7039d4a63e3d179e590d45b295c /weed/command/shell.go
parent05fe7a23669197a828889f0be7d60f85661f1042 (diff)
downloadseaweedfs-288c45a690e26c6e0d4b55b50ffb089e0c544c59.tar.xz
seaweedfs-288c45a690e26c6e0d4b55b50ffb089e0c544c59.zip
fix iitial filer url
Diffstat (limited to 'weed/command/shell.go')
-rw-r--r--weed/command/shell.go45
1 files changed, 37 insertions, 8 deletions
diff --git a/weed/command/shell.go b/weed/command/shell.go
index eae68c3be..7f971c477 100644
--- a/weed/command/shell.go
+++ b/weed/command/shell.go
@@ -1,6 +1,11 @@
package command
import (
+ "fmt"
+ "net/url"
+ "strconv"
+ "strings"
+
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/shell"
"github.com/chrislusf/seaweedfs/weed/util"
@@ -8,18 +13,15 @@ import (
)
var (
- shellOptions shell.ShellOptions
+ shellOptions shell.ShellOptions
+ shellInitialFilerUrl *string
+
)
func init() {
cmdShell.Run = runShell // break init cycle
shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")
- filerHost := cmdShell.Flag.String("filer.host", "localhost", "comma-separated filer server host")
- flierPort := cmdShell.Flag.Int64("filer.port", 8888, "comma-separated filer server port")
- directory := cmdShell.Flag.String("filer.dir", "/", "comma-separated filer server directory")
- shellOptions.FilerHost = *filerHost
- shellOptions.FilerPort = *flierPort
- shellOptions.Directory = *directory
+ shellInitialFilerUrl = cmdShell.Flag.String("filer.url", "http://localhost:8888/", "initial filer url")
}
var cmdShell = &Command{
@@ -36,8 +38,35 @@ func runShell(command *Command, args []string) bool {
util.LoadConfiguration("security", false)
shellOptions.GrpcDialOption = security.LoadClientTLS(viper.Sub("grpc"), "client")
+
+ var filerPwdErr error
+ shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, filerPwdErr = parseFilerUrl(*shellInitialFilerUrl)
+ if filerPwdErr != nil {
+ fmt.Printf("failed to parse url filer.url=%s : %v\n", *shellInitialFilerUrl, filerPwdErr)
+ return false
+ }
+
shell.RunShell(shellOptions)
return true
-} \ No newline at end of file
+}
+
+func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
+ if !strings.HasPrefix(entryPath, "http://") && !strings.HasPrefix(entryPath, "https://") {
+ entryPath = "http://" + entryPath
+ }
+
+ var u *url.URL
+ u, err = url.Parse(entryPath)
+ if err != nil {
+ return
+ }
+ filerServer = u.Hostname()
+ portString := u.Port()
+ if portString != "" {
+ filerPort, err = strconv.ParseInt(portString, 10, 32)
+ }
+ path = u.Path
+ return
+}