Merge pull request #17567 from swordqiu/hotfix/qj-disable-app-profiling-by-default

fix: disable application profiling by default
This commit is contained in:
Zexi Li
2023-07-19 01:33:03 +08:00
committed by GitHub
6 changed files with 17 additions and 4 deletions
+1
View File
@@ -151,6 +151,7 @@ var (
"is_slave_node",
"config_sync_period_seconds",
"enable_app_profiling",
// ############################
// db blacklist options
+9 -1
View File
@@ -73,6 +73,8 @@ type Application struct {
exception func(method, path string, body jsonutils.JSONObject, err error)
isTLS bool
enableProfiling bool
}
const (
@@ -553,7 +555,9 @@ func (app *Application) ListenAndServeTLSWithCleanup2(addr string, certFile, key
httpSrv := app.initServer(addr)
if isMaster {
app.addDefaultHandlers()
AddPProfHandler("", app)
if app.enableProfiling {
addPProfHandler("", app)
}
app.httpServer = httpSrv
app.registerCleanShutdown(app.httpServer, onStop)
} else {
@@ -665,3 +669,7 @@ func FetchEnv(ctx context.Context, w http.ResponseWriter, r *http.Request) (para
func (app *Application) GetContext() context.Context {
return app.context
}
func (app *Application) EnableProfiling() {
app.enableProfiling = true
}
+1 -1
View File
@@ -51,7 +51,7 @@ func CORSHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {
}
}*/
func AddPProfHandler(prefix string, app *Application) {
func addPProfHandler(prefix string, app *Application) {
pp := "/debug/pprof"
if prefix != "" {
prefix = fmt.Sprintf("%s/%s", prefix, pp)
+1 -2
View File
@@ -22,10 +22,9 @@ import (
"strconv"
"time"
"github.com/pkg/errors"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/gotypes"
)
+3
View File
@@ -37,6 +37,9 @@ func InitApp(options *common_options.BaseOptions, dbAccess bool) *appsrv.Applica
// if dbConn != nil {
// app.SetContext(appsrv.APP_CONTEXT_KEY_DB, dbConn)
//}
if options.EnableAppProfiling {
app.EnableProfiling()
}
return app
}
+2
View File
@@ -116,6 +116,8 @@ type BaseOptions struct {
PlatformName string `help:"identity name of this platform" default:"Cloudpods"`
PlatformNames map[string]string `help:"identity name of this platform by language"`
EnableAppProfiling bool `help:"enable profiling API" default:"false"`
}
const (