Skip to content

Commit

Permalink
Added pprof to discovery-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
stefin9898 committed May 17, 2023
1 parent 41a321c commit 268c443
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
5 changes: 4 additions & 1 deletion deployments/helm/configmapfiles/discovery-engine/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ recommend:
# license
license:
enabled: false
validate: "user-id"
validate: "user-id"

# pprof
pprof: false
4 changes: 3 additions & 1 deletion src/conf/local-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,6 @@ recommend:
license:
enabled: false
# validate can be user-id or platform-uuid
validate: "user-id"
validate: "user-id"

pprof: false
4 changes: 3 additions & 1 deletion src/conf/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ recommend:
license:
enabled: false
# validate can be user-id or platform-uuid
validate: "user-id"
validate: "user-id"

pprof: false
3 changes: 3 additions & 0 deletions src/libs/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ func SetDefaultConfig() {
viper.SetDefault("recommend.host-policy", true)
viper.SetDefault("recommend.admission-controller-policy", true)
viper.SetDefault("license.enabled", false)

// pprof
viper.SetDefault("pprof", false)
}

type cfgArray []string
Expand Down
23 changes: 19 additions & 4 deletions src/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package main

Check warning on line 1 in src/main.go

View workflow job for this annotation

GitHub Actions / go-lint

should have a package comment

import (
"fmt"
"math/rand"
"net"
"os"
"time"

"net/http"
_ "net/http/pprof"

"github.com/accuknox/auto-policy-discovery/src/cluster"
"github.com/accuknox/auto-policy-discovery/src/config"
"github.com/accuknox/auto-policy-discovery/src/libs"
Expand All @@ -10,10 +19,6 @@ import (
"github.com/rs/zerolog"
"github.com/spf13/viper"
"google.golang.org/grpc"
"math/rand"
"net"
"os"
"time"
)

var cfg cluster.Config
Expand All @@ -33,6 +38,16 @@ func init() {
logger.SetLogLevel(viper.GetString("logging.level"))
log = logger.GetInstance()

//Get pprof flag
pprof := viper.GetBool("pprof")
if pprof {
// Server for pprof
go func() {
log.Info().Msgf("pprof enabled on :6060\n")
fmt.Println(http.ListenAndServe(":6060", nil))
}()
}

log.Info().Msgf("NETWORK-POLICY: %+v", config.GetCfgNet())
log.Info().Msgf("CILIUM: %+v", config.GetCfgCiliumHubble())
log.Info().Msgf("SYSTEM-POLICY: %+v", config.GetCfgSys())
Expand Down

0 comments on commit 268c443

Please sign in to comment.