util: Add a pprof helper package
As it turns out, there are other helper packages out there. I wrote this before I realized that, and it didn't take me that long anyways.
This commit is contained in:
13
main.go
13
main.go
@@ -43,7 +43,8 @@ import (
|
||||
_ "github.com/purpleidea/mgmt/lang/gapi" // import so the gapi registers
|
||||
_ "github.com/purpleidea/mgmt/puppet" // import so the gapi registers
|
||||
_ "github.com/purpleidea/mgmt/puppet/langpuppet" // import so the gapi registers
|
||||
_ "github.com/purpleidea/mgmt/yamlgraph" // import so the gapi registers
|
||||
"github.com/purpleidea/mgmt/util/pprof"
|
||||
_ "github.com/purpleidea/mgmt/yamlgraph" // import so the gapi registers
|
||||
"go.etcd.io/etcd/server/v3/etcdmain"
|
||||
)
|
||||
|
||||
@@ -76,6 +77,16 @@ func main() {
|
||||
return // for safety
|
||||
}
|
||||
|
||||
// Run profiling if it's activated.
|
||||
// TODO: Should we pass a logger into this?
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
if err := pprof.Run(ctx); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
//return // redundant
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
cliUtil.LogSetup(debug)
|
||||
data := &cliUtil.Data{
|
||||
Program: program,
|
||||
|
||||
Reference in New Issue
Block a user