Commit dff606a3 authored by Jeromy's avatar Jeromy

write memory profiles every 30 seconds when enabled

parent fcb559eb
......@@ -447,14 +447,18 @@ func startProfiling() (func(), error) {
return nil, err
}
pprof.StartCPUProfile(ofi)
go func() {
for _ = range time.NewTicker(time.Second * 30).C {
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
}
}
}()
stopProfiling := func() {
pprof.StopCPUProfile()
defer ofi.Close() // captured by the closure
err := writeHeapProfileToFile()
if err != nil {
log.Critical(err)
}
}
return stopProfiling, nil
}
......@@ -487,7 +491,6 @@ func (ih *IntrHandler) Close() error {
return nil
}
// Handle starts handling the given signals, and will call the handler
// callback function each time a signal is catched. The function is passed
// the number of times the handler has been triggered in total, as
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment