X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b2b6c8a9ac127ba76dc0421782503e4574837f4d..a86a6544f54720c5941a32187235ef5287caee07:/lib/mount/command.go diff --git a/lib/mount/command.go b/lib/mount/command.go index da3f97b467..f88d977c4c 100644 --- a/lib/mount/command.go +++ b/lib/mount/command.go @@ -8,23 +8,28 @@ import ( "flag" "io" "log" + "net/http" + + // pprof is only imported to register its HTTP handlers + _ "net/http/pprof" "os" + "git.arvados.org/arvados.git/lib/cmd" "git.arvados.org/arvados.git/sdk/go/arvados" "git.arvados.org/arvados.git/sdk/go/arvadosclient" "git.arvados.org/arvados.git/sdk/go/keepclient" "github.com/arvados/cgofuse/fuse" ) -var Command = &cmd{} +var Command = &mountCommand{} -type cmd struct { +type mountCommand struct { // ready, if non-nil, will be closed when the mount is // initialized. If ready is non-nil, it RunCommand() should // not be called more than once, or when ready is already // closed. ready chan struct{} - // It is safe to call Unmount ounly after ready has been + // It is safe to call Unmount only after ready has been // closed. Unmount func() (ok bool) } @@ -33,21 +38,25 @@ type cmd struct { // // The "-d" fuse option (and perhaps other features) ignores the // stderr argument and prints to os.Stderr instead. -func (c *cmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { +func (c *mountCommand) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int { logger := log.New(stderr, prog+" ", 0) flags := flag.NewFlagSet(prog, flag.ContinueOnError) ro := flags.Bool("ro", false, "read-only") experimental := flags.Bool("experimental", false, "acknowledge this is an experimental command, and should not be used in production (required)") blockCache := flags.Int("block-cache", 4, "read cache size (number of 64MiB blocks)") - err := flags.Parse(args) - if err != nil { - logger.Print(err) - return 2 + pprof := flags.String("pprof", "", "serve Go profile data at `[addr]:port`") + if ok, code := cmd.ParseFlags(flags, prog, args, "[FUSE mount options]", stderr); !ok { + return code } if !*experimental { logger.Printf("error: experimental command %q used without --experimental flag", prog) return 2 } + if *pprof != "" { + go func() { + log.Println(http.ListenAndServe(*pprof, nil)) + }() + } client := arvados.NewClientFromEnv() ac, err := arvadosclient.New(client)