MCPcopy Create free account
hub / github.com/CPChain/chain / Setup

Function Setup

internal/debug/flags.go:82–103  ·  view source on GitHub ↗

Setup initializes profiling and logging based on the CLI flags. It should be called as early as possible in the program.

(ctx *cli.Context)

Source from the content-addressed store, hash-verified

80// Setup initializes profiling and logging based on the CLI flags.
81// It should be called as early as possible in the program.
82func Setup(ctx *cli.Context) error {
83 // profiling, tracing
84 runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)
85 Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name))
86 if traceFile := ctx.GlobalString(traceFlag.Name); traceFile != "" {
87 if err := Handler.StartGoTrace(traceFile); err != nil {
88 return err
89 }
90 }
91 if cpuFile := ctx.GlobalString(cpuprofileFlag.Name); cpuFile != "" {
92 if err := Handler.StartCPUProfile(cpuFile); err != nil {
93 return err
94 }
95 }
96
97 // pprof server
98 if ctx.GlobalBool(pprofFlag.Name) {
99 address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name))
100 StartPProf(address)
101 }
102 return nil
103}
104
105func StartPProf(address string) {
106 // Hook go-metrics into expvar on any /debug/metrics request, load all vars

Callers

nothing calls this directly

Calls 4

StartPProfFunction · 0.85
SetBlockProfileRateMethod · 0.80
StartGoTraceMethod · 0.45
StartCPUProfileMethod · 0.45

Tested by

no test coverage detected