X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b2b6c8a9ac127ba76dc0421782503e4574837f4d..0348478eba20e59c3305dd5eda702d9192b45058:/lib/mount/command.go diff --git a/lib/mount/command.go b/lib/mount/command.go index da3f97b467..e92af24075 100644 --- a/lib/mount/command.go +++ b/lib/mount/command.go @@ -8,6 +8,9 @@ import ( "flag" "io" "log" + "net/http" + // pprof is only imported to register its HTTP handlers + _ "net/http/pprof" "os" "git.arvados.org/arvados.git/sdk/go/arvados" @@ -24,7 +27,7 @@ type cmd struct { // 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) } @@ -39,6 +42,7 @@ func (c *cmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, st 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)") + pprof := flags.String("pprof", "", "serve Go profile data at `[addr]:port`") err := flags.Parse(args) if err != nil { logger.Print(err) @@ -48,6 +52,11 @@ func (c *cmd) RunCommand(prog string, args []string, stdin io.Reader, stdout, st 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)