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.

78 lines
3.8 KiB

  1. package command
  2. import (
  3. "os"
  4. "time"
  5. )
  6. type MountOptions struct {
  7. filer *string
  8. filerMountRootPath *string
  9. dir *string
  10. dirAutoCreate *bool
  11. collection *string
  12. replication *string
  13. ttlSec *int
  14. chunkSizeLimitMB *int
  15. concurrentWriters *int
  16. cacheDir *string
  17. cacheSizeMB *int64
  18. dataCenter *string
  19. allowOthers *bool
  20. umaskString *string
  21. nonempty *bool
  22. outsideContainerClusterMode *bool
  23. uidMap *string
  24. gidMap *string
  25. }
  26. var (
  27. mountOptions MountOptions
  28. mountCpuProfile *string
  29. mountMemProfile *string
  30. mountReadRetryTime *time.Duration
  31. )
  32. func init() {
  33. cmdMount.Run = runMount // break init cycle
  34. mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
  35. mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
  36. mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
  37. mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
  38. mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
  39. mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
  40. mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
  41. mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
  42. mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 0, "limit concurrent goroutine writers if not 0")
  43. mountOptions.cacheDir = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
  44. mountOptions.cacheSizeMB = cmdMount.Flag.Int64("cacheCapacityMB", 1000, "local file chunk cache capacity in MB (0 will disable cache)")
  45. mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
  46. mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
  47. mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
  48. mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
  49. mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access volume servers with publicUrl")
  50. mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
  51. mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
  52. mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
  53. mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
  54. mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
  55. }
  56. var cmdMount = &Command{
  57. UsageLine: "mount -filer=localhost:8888 -dir=/some/dir",
  58. Short: "mount weed filer to a directory as file system in userspace(FUSE)",
  59. Long: `mount weed filer to userspace.
  60. Pre-requisites:
  61. 1) have SeaweedFS master and volume servers running
  62. 2) have a "weed filer" running
  63. These 2 requirements can be achieved with one command "weed server -filer=true"
  64. This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
  65. Linux, and OS X.
  66. On OS X, it requires OSXFUSE (http://osxfuse.github.com/).
  67. `,
  68. }