diff options
| author | Chris Lu <chris.lu@gmail.com> | 2016-07-03 15:39:57 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2016-07-03 15:39:57 -0700 |
| commit | b38ff39e8bab672520b7479a5e057fedc00fa101 (patch) | |
| tree | fd45646a2f2e45be69a3b2298b3b0f4622419b86 /weed/command/master.go | |
| parent | d981eb282fc8c6b2629c86be80297ff2da17703d (diff) | |
| download | seaweedfs-b38ff39e8bab672520b7479a5e057fedc00fa101.tar.xz seaweedfs-b38ff39e8bab672520b7479a5e057fedc00fa101.zip | |
add master profiling option
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index aed8fc793..cb6b492e3 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -4,6 +4,7 @@ import ( "net/http" "os" "runtime" + "runtime/pprof" "strconv" "strings" "time" @@ -42,6 +43,7 @@ var ( garbageThreshold = cmdMaster.Flag.String("garbageThreshold", "0.3", "threshold to vacuum and reclaim spaces") masterWhiteListOption = cmdMaster.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.") masterSecureKey = cmdMaster.Flag.String("secure.secret", "", "secret to encrypt Json Web Token(JWT)") + masterCpuProfile = cmdMaster.Flag.String("cpuprofile", "", "cpu profile output file") masterWhiteList []string ) @@ -51,6 +53,14 @@ func runMaster(cmd *Command, args []string) bool { *mMaxCpu = runtime.NumCPU() } runtime.GOMAXPROCS(*mMaxCpu) + if *masterCpuProfile != "" { + f, err := os.Create(*masterCpuProfile) + if err != nil { + glog.Fatal(err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } if err := util.TestFolderWritable(*metaFolder); err != nil { glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *metaFolder, err) } |
