You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

3 years ago
  1. package command
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/mount"
  6. "github.com/hanwen/go-fuse/v2/fs"
  7. "net/http"
  8. "os"
  9. "strconv"
  10. "time"
  11. "github.com/chrislusf/seaweedfs/weed/util"
  12. "github.com/chrislusf/seaweedfs/weed/util/grace"
  13. )
  14. func runMount2(cmd *Command, args []string) bool {
  15. if *mountOptions.debug {
  16. go http.ListenAndServe(fmt.Sprintf(":%d", *mountOptions.debugPort), nil)
  17. }
  18. grace.SetupProfiling(*mountCpuProfile, *mountMemProfile)
  19. if *mountReadRetryTime < time.Second {
  20. *mountReadRetryTime = time.Second
  21. }
  22. util.RetryWaitTime = *mountReadRetryTime
  23. umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64)
  24. if umaskErr != nil {
  25. fmt.Printf("can not parse umask %s", *mountOptions.umaskString)
  26. return false
  27. }
  28. if len(args) > 0 {
  29. return false
  30. }
  31. return RunMount2(&mount2Options, os.FileMode(umask))
  32. }
  33. func RunMount2(option *Mount2Options, umask os.FileMode) bool {
  34. opts := &fs.Options{}
  35. opts.Debug = true
  36. server, err := fs.Mount(*option.dir, &mount.WeedFS{}, opts)
  37. if err != nil {
  38. glog.Fatalf("Mount fail: %v", err)
  39. }
  40. server.Wait()
  41. return true
  42. }