mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
server add memory profiling
This commit is contained in:
parent
48188abc7b
commit
a1e18a1384
|
@ -2,8 +2,8 @@ package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util/grace"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
type ServerOptions struct {
|
type ServerOptions struct {
|
||||||
cpuprofile *string
|
cpuprofile *string
|
||||||
|
memprofile *string
|
||||||
v VolumeServerOptions
|
v VolumeServerOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
serverOptions.cpuprofile = cmdServer.Flag.String("cpuprofile", "", "cpu profile output file")
|
serverOptions.cpuprofile = cmdServer.Flag.String("cpuprofile", "", "cpu profile output file")
|
||||||
|
serverOptions.memprofile = cmdServer.Flag.String("memprofile", "", "memory profile output file")
|
||||||
|
|
||||||
masterOptions.port = cmdServer.Flag.Int("master.port", 9333, "master server http listen port")
|
masterOptions.port = cmdServer.Flag.Int("master.port", 9333, "master server http listen port")
|
||||||
masterOptions.metaFolder = cmdServer.Flag.String("master.dir", "", "data directory to store meta data, default to same as -dir specified")
|
masterOptions.metaFolder = cmdServer.Flag.String("master.dir", "", "data directory to store meta data, default to same as -dir specified")
|
||||||
|
@ -137,14 +139,7 @@ func runServer(cmd *Command, args []string) bool {
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
util.LoadConfiguration("master", false)
|
util.LoadConfiguration("master", false)
|
||||||
|
|
||||||
if *serverOptions.cpuprofile != "" {
|
grace.SetupProfiling(*serverOptions.cpuprofile, *serverOptions.memprofile)
|
||||||
f, err := os.Create(*serverOptions.cpuprofile)
|
|
||||||
if err != nil {
|
|
||||||
glog.Fatal(err)
|
|
||||||
}
|
|
||||||
pprof.StartCPUProfile(f)
|
|
||||||
defer pprof.StopCPUProfile()
|
|
||||||
}
|
|
||||||
|
|
||||||
if *isStartingS3 {
|
if *isStartingS3 {
|
||||||
*isStartingFiler = true
|
*isStartingFiler = true
|
||||||
|
|
Loading…
Reference in a new issue