Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
flags memory profile threshold
p0nydc0e94fea90b
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.goindex 247188a58b..5fb6d9292d 100644--- a/backend/bin/server/cmd/profile.go+++ b/backend/bin/server/cmd/profile.go@@ -16,7 +16,7 @@ func getBaseProfile(dataDir string) *config.Profile {sampleDatabasePort = flags.port + 3}- return &config.Profile{+ config := &config.Profile{ExternalURL: flags.externalURL,Port: flags.port, // Using flags.port as our gRPC server port.DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.@@ -24,7 +24,6 @@ func getBaseProfile(dataDir string) *config.Profile {HA: flags.ha,SaaS: flags.saas,EnableJSONLogging: flags.enableJSONLogging,- Debug: flags.debug,IsDocker: isDocker(),DataDir: dataDir,Demo: flags.demo,@@ -34,6 +33,10 @@ func getBaseProfile(dataDir string) *config.Profile {DeployID: uuid.NewString()[:8],LastActiveTS: time.Now().Unix(),}++ config.RuntimeDebug.Store(flags.debug)+ config.RuntimeMemoryProfileThreshold.Store(flags.memoryProfileThreshold)+ return config}func isDocker() bool {diff --git a/backend/bin/server/cmd/profile_dev.go b/backend/bin/server/cmd/profile_dev.goindex 36b946c20e..d12b4bca05 100644--- a/backend/bin/server/cmd/profile_dev.go+++ b/backend/bin/server/cmd/profile_dev.go@@ -9,7 +9,6 @@ import (func activeProfile(dataDir string) *config.Profile {p := getBaseProfile(dataDir)- p.RuntimeDebug.Store(p.Debug)p.Mode = common.ReleaseModeDev// Metric collection is disabled in dev mode.// p.MetricConnectionKey = "3zcZLeX3ahvlueEJqNyJysGfVAErsjjT"diff --git a/backend/bin/server/cmd/profile_release.go b/backend/bin/server/cmd/profile_release.goindex 37193cafb1..2d89fc4b93 100644--- a/backend/bin/server/cmd/profile_release.go+++ b/backend/bin/server/cmd/profile_release.go@@ -9,7 +9,6 @@ import (func activeProfile(dataDir string) *config.Profile {p := getBaseProfile(dataDir)- p.RuntimeDebug.Store(p.Debug)p.Mode = common.ReleaseModeProd// Enable metric if it's not explicitly disabled and it's not running in demo mode.if !flags.disableMetric && !p.Demo {diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.goindex f0b9c021ba..c81ddbae67 100644--- a/backend/bin/server/cmd/root.go+++ b/backend/bin/server/cmd/root.go@@ -76,6 +76,8 @@ var (disableMetric bool// disableSample is the flag to disable the sample instance.disableSample bool+ // memoryProfileThreshold is the threshold of memory usage in bytes to trigger a memory profile.+ memoryProfileThreshold int64}rootCmd = &cobra.Command{@@ -115,6 +117,7 @@ func init() {rootCmd.PersistentFlags().BoolVar(&flags.debug, "debug", false, "whether to enable debug level logging")rootCmd.PersistentFlags().BoolVar(&flags.disableMetric, "disable-metric", false, "disable the metric collector")rootCmd.PersistentFlags().BoolVar(&flags.disableSample, "disable-sample", false, "disable the sample instance")+ rootCmd.PersistentFlags().Int64Var(&flags.memoryProfileThreshold, "memory-profile-threshold", 0, "the threshold of memory usage in bytes to trigger a memory profile")}// -----------------------------------Command Line Config END--------------------------------------diff --git a/backend/component/config/profile.go b/backend/component/config/profile.goindex 484b6e57d1..89d9af2585 100644--- a/backend/component/config/profile.go+++ b/backend/component/config/profile.go@@ -27,8 +27,6 @@ type Profile struct {SaaS bool// When enabled output logs in json formatEnableJSONLogging bool- // Debug is the startup time debug- Debug bool// DataDir is the directory stores the data including Bytebase's own database, backups, etc.DataDir string// Demo mode.@@ -54,6 +52,10 @@ type Profile struct {// can be set in runtimeRuntimeDebug atomic.Bool+ // RuntimeMemoryProfileThreshold is the memory threshold in bytes for the server to trigger a pprof memory profile.+ // can be set in runtime+ // 0 means no threshold.+ RuntimeMemoryProfileThreshold atomic.Int64}// UseEmbedDB returns whether to use embedDB.