From 2a2c97c4cb090e73f4ccbc54c58393bf067fa182 Mon Sep 17 00:00:00 2001 From: bjwswang Date: Tue, 22 Aug 2023 00:59:24 +0800 Subject: [PATCH] fix: add http probe and profiling; update to correct arcadia image Signed-off-by: bjwswang --- charts/arcadia/Chart.yaml | 2 +- charts/arcadia/values.yaml | 2 +- main.go | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/charts/arcadia/Chart.yaml b/charts/arcadia/Chart.yaml index d435f9650..1962c0433 100644 --- a/charts/arcadia/Chart.yaml +++ b/charts/arcadia/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: arcadia description: A Helm chart(KubeBB Component) for KubeAGI Arcadia type: application -version: 0.1.2 +version: 0.1.3 appVersion: "0.0.0" keywords: - kubeagi diff --git a/charts/arcadia/values.yaml b/charts/arcadia/values.yaml index 4e5366a3a..7b88bc8da 100644 --- a/charts/arcadia/values.yaml +++ b/charts/arcadia/values.yaml @@ -1,5 +1,5 @@ deployment: - image: kubeagi/arcadia:latest + image: kubebb/arcadia:latest imagePullPolcy: IfNotPresent resources: limits: diff --git a/main.go b/main.go index 6de900844..c63c9ac13 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,8 @@ package main import ( "flag" + "net/http" + "net/http/pprof" "os" "path/filepath" "strconv" @@ -51,11 +53,18 @@ func init() { } func main() { - var configFile string + var ( + configFile string + enableProfiling bool + probeAddr string + ) flag.StringVar(&configFile, "config", "", "The controller will load its initial configuration from this file. "+ "Omit this flag to use the default configuration values. "+ "Command-line flags override configuration from this file.") + flag.BoolVar(&enableProfiling, "profiling", true, + "Enable profiling via web interface host:port/debug/pprof/") + flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") opts := zap.Options{ Development: true, } @@ -65,7 +74,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) var err error - options := ctrl.Options{Scheme: scheme} + options := ctrl.Options{Scheme: scheme, HealthProbeBindAddress: probeAddr} if configFile != "" { options, err = options.AndFrom(ctrl.ConfigFile().AtPath(configFile)) if err != nil { @@ -148,6 +157,14 @@ func main() { os.Exit(1) } + if enableProfiling { + _ = mgr.AddMetricsExtraHandler("/debug/pprof/", http.HandlerFunc(pprof.Index)) + _ = mgr.AddMetricsExtraHandler("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline)) + _ = mgr.AddMetricsExtraHandler("/debug/pprof/profile", http.HandlerFunc(pprof.Profile)) + _ = mgr.AddMetricsExtraHandler("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol)) + _ = mgr.AddMetricsExtraHandler("/debug/pprof/trace", http.HandlerFunc(pprof.Trace)) + } + setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager")