mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-13 08:34:44 +08:00
add security to cpu profile
This commit is contained in:
parent
32dfcecdff
commit
bfc437bc9f
1 changed files with 4 additions and 3 deletions
|
@ -1,18 +1,19 @@
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
|
"github.com/gravitl/netmaker/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartCPUProfiling() *os.File {
|
func StartCPUProfiling() *os.File {
|
||||||
f, err := os.OpenFile("/root/data/cpu.prof", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0755)
|
f, err := os.OpenFile("/root/data/cpu.prof", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("could not create CPU profile: ", err)
|
logger.Log(0, "could not create CPU profile: ", err.Error())
|
||||||
}
|
}
|
||||||
if err := pprof.StartCPUProfile(f); err != nil {
|
if err := pprof.StartCPUProfile(f); err != nil {
|
||||||
log.Fatal("could not start CPU profile: ", err)
|
logger.Log(0, "could not start CPU profile: ", err.Error())
|
||||||
}
|
}
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue