diff --git a/cmd/versitygw/main.go b/cmd/versitygw/main.go index e711a300..b5bc8883 100644 --- a/cmd/versitygw/main.go +++ b/cmd/versitygw/main.go @@ -19,6 +19,8 @@ import ( "crypto/tls" "fmt" "log" + "net/http" + _ "net/http/pprof" "os" "github.com/gofiber/fiber/v2" @@ -44,6 +46,7 @@ var ( accessLog string healthPath string debug bool + pprof string quiet bool iamDir string ldapURL, ldapBindDN, ldapPassword string @@ -187,6 +190,12 @@ func initFlags() []cli.Flag { EnvVars: []string{"VGW_DEBUG"}, Destination: &debug, }, + &cli.StringFlag{ + Name: "pprof", + Usage: "enable pprof debug on specified port", + EnvVars: []string{"VGW_PPROF"}, + Destination: &pprof, + }, &cli.BoolFlag{ Name: "quiet", Usage: "silence stdout request logging output", @@ -373,6 +382,14 @@ func runGateway(ctx context.Context, be backend.Backend) error { return fmt.Errorf("root user access and secret key must be provided") } + if pprof != "" { + // listen on specified port for pprof debug + // point browser to http:///debug/pprof/ + go func() { + log.Fatal(http.ListenAndServe(pprof, nil)) + }() + } + app := fiber.New(fiber.Config{ AppName: "versitygw", ServerHeader: "VERSITYGW",