You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
cpuOut, err := os.Create(*cpuprofile)
will create a new variablecpuOut
, which is different with global variablevar cpuOut *os.File
. Global variablevar cpuOut *os.File
is never set and one error will be created when functionCleanup()
is called.Besides, the
cpuprofile
will not be closed in time.The text was updated successfully, but these errors were encountered: