mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-11 11:19:05 +08:00
feat(ipfs2/main) port mem-profiling from previous main
was added 5 days ago in...
7510ef2081
This commit is contained in:
parent
46f1afbe08
commit
96fd88e916
@ -22,12 +22,21 @@ import (
|
||||
// log is the command logger
|
||||
var log = u.Logger("cmd/ipfs")
|
||||
|
||||
const heapProfile = "ipfs.mprof"
|
||||
|
||||
func main() {
|
||||
args := os.Args[1:]
|
||||
req, root := createRequest(args)
|
||||
handleOptions(req, root)
|
||||
res := callCommand(req, root)
|
||||
outputResponse(res)
|
||||
|
||||
if u.Debug {
|
||||
err := writeHeapProfileToFile()
|
||||
if err != nil {
|
||||
log.Critical(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createRequest(args []string) (cmds.Request, *cmds.Command) {
|
||||
@ -232,3 +241,12 @@ func getConfig(path string) (*config.Config, error) {
|
||||
|
||||
return config.Load(configFile)
|
||||
}
|
||||
|
||||
func writeHeapProfileToFile() error {
|
||||
mprof, err := os.Create(heapProfile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer mprof.Close()
|
||||
return pprof.WriteHeapProfile(mprof)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user