-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
package service
...
var cpuOut *os.File
...
// BeforeRun takes care of necessary actions such as creating files
// before the beat should run.
func BeforeRun() {
logger := logp.NewLogger("service")
if withCPUProfile() {
cpuOut, err := os.Create(*cpuprofile)
....
}
...
}
cpuOut, err := os.Create(*cpuprofile) will create a new variable cpuOut, which is different with global variable var cpuOut *os.File. Global variable var cpuOut *os.File is never set and one error will be created when function Cleanup() is called.
func Cleanup() {
logger := logp.NewLogger("service")
if withCPUProfile() {
pprof.StopCPUProfile()
cpuOut.Close() // -------- cpuOut is nil
}
...
}
Besides, the cpuprofile will not be closed in time.
Metadata
Metadata
Assignees
Labels
No labels