From 489e1829b7847ff95102ec64108a7ee125b650a5 Mon Sep 17 00:00:00 2001 From: zymap Date: Fri, 20 Sep 2024 18:42:37 +0800 Subject: [PATCH] Add pprof flag for the server and coordinator --- ### Motivation Enable the pprof to debug issues. --- cmd/coordinator/cmd.go | 4 ++++ cmd/server/cmd.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/coordinator/cmd.go b/cmd/coordinator/cmd.go index 26dea902..e62d1a5c 100644 --- a/cmd/coordinator/cmd.go +++ b/cmd/coordinator/cmd.go @@ -72,6 +72,10 @@ func init() { Cmd.Flags().StringVar(&peerTLS.TrustedCaFile, "peer-tls-trusted-ca-file", "", "Peer tls trusted ca file") Cmd.Flags().BoolVar(&peerTLS.InsecureSkipVerify, "peer-tls-insecure-skip-verify", false, "Peer tls insecure skip verify") Cmd.Flags().StringVar(&peerTLS.ServerName, "peer-tls-server-name", "", "Peer tls server name") + + // pprof section + Cmd.PersistentFlags().BoolVar(&common.PprofEnable, "profile", false, "Enable pprof profiler") + Cmd.PersistentFlags().StringVar(&common.PprofBindAddress, "profile-bind-address", "127.0.0.1:6060", "Bind address for pprof") } func validate(*cobra.Command, []string) error { diff --git a/cmd/server/cmd.go b/cmd/server/cmd.go index 1bcfd208..07b9e580 100644 --- a/cmd/server/cmd.go +++ b/cmd/server/cmd.go @@ -85,6 +85,10 @@ func init() { Cmd.Flags().StringVar(&peerTLS.TrustedCaFile, "peer-tls-trusted-ca-file", "", "Peer tls trusted ca file") Cmd.Flags().BoolVar(&peerTLS.InsecureSkipVerify, "peer-tls-insecure-skip-verify", false, "Peer tls insecure skip verify") Cmd.Flags().StringVar(&peerTLS.ServerName, "peer-tls-server-name", "", "Peer tls server name") + + // pprof section + Cmd.PersistentFlags().BoolVar(&common.PprofEnable, "profile", false, "Enable pprof profiler") + Cmd.PersistentFlags().StringVar(&common.PprofBindAddress, "profile-bind-address", "127.0.0.1:6060", "Bind address for pprof") } func exec(*cobra.Command, []string) {