shell.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package command
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/security"
  5. "github.com/chrislusf/seaweedfs/weed/shell"
  6. "github.com/chrislusf/seaweedfs/weed/util"
  7. )
  8. var (
  9. shellOptions shell.ShellOptions
  10. shellInitialFiler *string
  11. )
  12. func init() {
  13. cmdShell.Run = runShell // break init cycle
  14. shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")
  15. shellInitialFiler = cmdShell.Flag.String("filer", "localhost:8888", "filer host and port")
  16. }
  17. var cmdShell = &Command{
  18. UsageLine: "shell",
  19. Short: "run interactive administrative commands",
  20. Long: `run interactive administrative commands.
  21. `,
  22. }
  23. func runShell(command *Command, args []string) bool {
  24. util.LoadConfiguration("security", false)
  25. shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
  26. var err error
  27. shellOptions.FilerHost, shellOptions.FilerPort, err = util.ParseHostPort(*shellInitialFiler)
  28. if err != nil {
  29. fmt.Printf("failed to parse filer %s: %v\n", *shellInitialFiler, err)
  30. return false
  31. }
  32. shellOptions.Directory = "/"
  33. shell.RunShell(shellOptions)
  34. return true
  35. }