mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #17567 from swordqiu/hotfix/qj-disable-app-profiling-by-default
fix: disable application profiling by default
This commit is contained in:
@@ -151,6 +151,7 @@ var (
|
||||
|
||||
"is_slave_node",
|
||||
"config_sync_period_seconds",
|
||||
"enable_app_profiling",
|
||||
|
||||
// ############################
|
||||
// db blacklist options
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user