20461: Add -pprof-dir option to slice subcommand.
authorTom Clegg <tom@curii.com>
Wed, 2 Aug 2023 17:31:31 +0000 (13:31 -0400)
committerTom Clegg <tom@curii.com>
Wed, 2 Aug 2023 17:31:31 +0000 (13:31 -0400)
refs #20461

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

slice.go

index 057ac5fa9d57e093ef07de404cf5e147cc5230dc..63e751c8da9aa9a245a64d94c3948c4e0443c06e 100644 (file)
--- a/slice.go
+++ b/slice.go
@@ -37,6 +37,7 @@ func (cmd *slicecmd) RunCommand(prog string, args []string, stdin io.Reader, std
        flags := flag.NewFlagSet("", flag.ContinueOnError)
        flags.SetOutput(stderr)
        pprof := flags.String("pprof", "", "serve Go profile data at http://`[addr]:port`")
+       pprofdir := flags.String("pprof-dir", "", "write Go profile data to `directory` periodically")
        runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
        projectUUID := flags.String("project", "", "project `UUID` for output data")
        priority := flags.Int("priority", 500, "container request priority")
@@ -61,6 +62,9 @@ func (cmd *slicecmd) RunCommand(prog string, args []string, stdin io.Reader, std
                        log.Println(http.ListenAndServe(*pprof, nil))
                }()
        }
+       if *pprofdir != "" {
+               go writeProfilesPeriodically(*pprofdir)
+       }
 
        if !*runlocal {
                runner := arvadosContainerRunner{