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.

80 lines
3.7 KiB

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