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.

86 lines
4.1 KiB

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