mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
added --pprof to volume servers
This commit is contained in:
parent
c38066be89
commit
03e8f976d9
|
@ -3,6 +3,7 @@ package command
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
httppprof "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
@ -32,14 +33,14 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type VolumeServerOptions struct {
|
type VolumeServerOptions struct {
|
||||||
port *int
|
port *int
|
||||||
publicPort *int
|
publicPort *int
|
||||||
folders []string
|
folders []string
|
||||||
folderMaxLimits []int
|
folderMaxLimits []int
|
||||||
ip *string
|
ip *string
|
||||||
publicUrl *string
|
publicUrl *string
|
||||||
bindIp *string
|
bindIp *string
|
||||||
masters *string
|
masters *string
|
||||||
// pulseSeconds *int
|
// pulseSeconds *int
|
||||||
idleConnectionTimeout *int
|
idleConnectionTimeout *int
|
||||||
dataCenter *string
|
dataCenter *string
|
||||||
|
@ -53,6 +54,7 @@ type VolumeServerOptions struct {
|
||||||
compactionMBPerSecond *int
|
compactionMBPerSecond *int
|
||||||
fileSizeLimitMB *int
|
fileSizeLimitMB *int
|
||||||
minFreeSpacePercent []float32
|
minFreeSpacePercent []float32
|
||||||
|
pprof *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -74,6 +76,7 @@ func init() {
|
||||||
v.memProfile = cmdVolume.Flag.String("memprofile", "", "memory profile output file")
|
v.memProfile = cmdVolume.Flag.String("memprofile", "", "memory profile output file")
|
||||||
v.compactionMBPerSecond = cmdVolume.Flag.Int("compactionMBps", 0, "limit background compaction or copying speed in mega bytes per second")
|
v.compactionMBPerSecond = cmdVolume.Flag.Int("compactionMBps", 0, "limit background compaction or copying speed in mega bytes per second")
|
||||||
v.fileSizeLimitMB = cmdVolume.Flag.Int("fileSizeLimitMB", 256, "limit file size to avoid out of memory")
|
v.fileSizeLimitMB = cmdVolume.Flag.Int("fileSizeLimitMB", 256, "limit file size to avoid out of memory")
|
||||||
|
v.pprof = cmdVolume.Flag.Bool("pprof", false, "enable pprof http handlers. precludes --memprofile and --cpuprofile")
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmdVolume = &Command{
|
var cmdVolume = &Command{
|
||||||
|
@ -96,7 +99,12 @@ func runVolume(cmd *Command, args []string) bool {
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
|
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
grace.SetupProfiling(*v.cpuProfile, *v.memProfile)
|
|
||||||
|
// If --pprof is set we assume the caller wants to be able to collect
|
||||||
|
// cpu and memory profiles via go tool pprof
|
||||||
|
if !*v.pprof {
|
||||||
|
grace.SetupProfiling(*v.cpuProfile, *v.memProfile)
|
||||||
|
}
|
||||||
|
|
||||||
v.startVolumeServer(*volumeFolders, *maxVolumeCounts, *volumeWhiteListOption, *minFreeSpacePercent)
|
v.startVolumeServer(*volumeFolders, *maxVolumeCounts, *volumeWhiteListOption, *minFreeSpacePercent)
|
||||||
|
|
||||||
|
@ -157,6 +165,14 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
|
||||||
publicVolumeMux = http.NewServeMux()
|
publicVolumeMux = http.NewServeMux()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *v.pprof {
|
||||||
|
volumeMux.HandleFunc("/debug/pprof/", httppprof.Index)
|
||||||
|
volumeMux.HandleFunc("/debug/pprof/cmdline", httppprof.Cmdline)
|
||||||
|
volumeMux.HandleFunc("/debug/pprof/profile", httppprof.Profile)
|
||||||
|
volumeMux.HandleFunc("/debug/pprof/symbol", httppprof.Symbol)
|
||||||
|
volumeMux.HandleFunc("/debug/pprof/trace", httppprof.Trace)
|
||||||
|
}
|
||||||
|
|
||||||
volumeNeedleMapKind := storage.NeedleMapInMemory
|
volumeNeedleMapKind := storage.NeedleMapInMemory
|
||||||
switch *v.indexType {
|
switch *v.indexType {
|
||||||
case "leveldb":
|
case "leveldb":
|
||||||
|
|
Loading…
Reference in a new issue