mount2.go 4.1 KB

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