Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

add debug option to generate full goroutine stack dump

Chris Lu0d6f45cb464e
diff --git a/weed/command/filer.go b/weed/command/filer.go
index a723b4d8a9..eb7078a9d6 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -3,6 +3,7 @@ package command
import (
"fmt"
"net/http"
+ _ "net/http/pprof"
"os"
"strconv"
"strings"
@@ -50,6 +51,7 @@ type FilerOptions struct {
saveToFilerLimit *int
defaultLevelDbDirectory *string
concurrentUploadLimitMB *int
+ debug *bool
}
func init() {
@@ -73,6 +75,7 @@ func init() {
f.saveToFilerLimit = cmdFiler.Flag.Int("saveToFilerLimit", 0, "files smaller than this limit will be saved in filer store")
f.defaultLevelDbDirectory = cmdFiler.Flag.String("defaultStoreDir", ".", "if filer.toml is empty, use an embedded filer store in the directory")
f.concurrentUploadLimitMB = cmdFiler.Flag.Int("concurrentUploadLimitMB", 128, "limit total concurrent upload size")
+ f.debug = cmdFiler.Flag.Bool("debug", false, "generate full goroutine stack dump http://localhost:6060/debug/pprof/goroutine?debug=2")
// start s3 on filer
filerStartS3 = cmdFiler.Flag.Bool("s3", false, "whether to start S3 gateway")
@@ -122,6 +125,9 @@ var cmdFiler = &Command{
}
func runFiler(cmd *Command, args []string) bool {
+ if *f.debug {
+ go http.ListenAndServe("localhost:6060", nil)
+ }
util.LoadConfiguration("security", false)
diff --git a/weed/command/server.go b/weed/command/server.go
index 97f1176659..83aa5e84c0 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -3,6 +3,7 @@ package command
import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/util/grace"
+ "net/http"
"os"
"strings"
"time"
@@ -16,6 +17,7 @@ import (
type ServerOptions struct {
cpuprofile *string
memprofile *string
+ debug *bool
v VolumeServerOptions
}
@@ -78,6 +80,7 @@ var (
func init() {
serverOptions.cpuprofile = cmdServer.Flag.String("cpuprofile", "", "cpu profile output file")
serverOptions.memprofile = cmdServer.Flag.String("memprofile", "", "memory profile output file")
+ serverOptions.debug = cmdServer.Flag.Bool("debug", false, "generate full goroutine stack dump http://localhost:6060/debug/pprof/goroutine?debug=2")
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")
@@ -139,6 +142,10 @@ func init() {
func runServer(cmd *Command, args []string) bool {
+ if *serverOptions.debug {
+ go http.ListenAndServe("localhost:6060", nil)
+ }
+
util.LoadConfiguration("security", false)
util.LoadConfiguration("master", false)