github.com/Schaudge/grailbase@v0.0.0-20240223061707-44c758a471c0/cmd/grail-fuse/main.go (about) 1 package main 2 3 import ( 4 "context" 5 "flag" 6 "fmt" 7 "net/http" 8 _ "net/http/pprof" 9 "os" 10 11 "github.com/Schaudge/grailbase/cmd/grail-fuse/gfs" 12 "github.com/Schaudge/grailbase/file" 13 "github.com/Schaudge/grailbase/file/s3file" 14 "github.com/Schaudge/grailbase/log" 15 ) 16 17 func main() { 18 flag.Usage = func() { 19 fmt.Fprintf(flag.CommandLine.Output(), `Usage: 20 %s [flags...] MOUNTDIR 21 22 To unmount the file system, run "fusermount -u MOUNTDIR". 23 `, os.Args[0]) 24 flag.PrintDefaults() 25 } 26 remoteRootDirFlag := flag.String("remote-root-dir", "s3://", `Remote root directory`) 27 logDirFlag := flag.String("log-dir", "", `Directory to store log files. 28 If empty, log messages are sent to stderr`) 29 tmpDirFlag := flag.String("tmp-dir", "", `Tmp directory location. If empty, /tmp/gfscache-<uid> is used`) 30 daemonFlag := flag.Bool("daemon", false, "Run in background") 31 httpFlag := flag.String("http", "localhost:54321", "Run an HTTP status server") 32 log.AddFlags() 33 log.SetFlags(log.Lmicroseconds | log.Lshortfile) 34 flag.Parse() 35 args := flag.Args() 36 if len(args) != 1 { 37 log.Panic("fuse: missing mount point") 38 } 39 if len(*httpFlag) > 0 { 40 log.Printf("starting status server at %s", *httpFlag) 41 go func() { 42 log.Print(http.ListenAndServe(*httpFlag, nil)) 43 }() 44 } 45 file.RegisterImplementation("s3", func() file.Implementation { 46 return s3file.NewImplementation(s3file.NewDefaultProvider(), s3file.Options{}) 47 }) 48 gfs.Main(context.Background(), *remoteRootDirFlag, args[0], *daemonFlag, *tmpDirFlag, *logDirFlag) 49 }