mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Ensure reference fileCPU is not overwritten
Would previously happen if memory profiling was already started. Now using os.File.Stat beforehand to check if a handler of the file is already active and confirm the status of profiling. This required changing the type of the reference fileCPU from io.Closer to *os.File. Asserting the type would have worked as well.
This commit is contained in:
committed by
Dan Christian Bogos
parent
1c490a9020
commit
218ad92635
@@ -21,7 +21,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -354,7 +353,7 @@ func main() {
|
||||
go singnalHandler(shdWg, shdChan)
|
||||
|
||||
var cS *cores.CoreService
|
||||
var cpuProf io.Closer
|
||||
var cpuProf *os.File
|
||||
if *cpuProfDir != utils.EmptyString {
|
||||
cpuPath := filepath.Join(*cpuProfDir, utils.CpuPathCgr)
|
||||
cpuProf, err = cores.StartCPUProfiling(cpuPath)
|
||||
@@ -371,7 +370,7 @@ func main() {
|
||||
}
|
||||
pprof.StopCPUProfile()
|
||||
if err := cpuProf.Close(); err != nil {
|
||||
log.Printf("could not close file %q: %v", cpuProf.(*os.File).Name(), err)
|
||||
log.Print(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user