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.

60 lines
1.3 KiB

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