Skip to content

Commit 75288c9

Browse files
Merge pull request #313 from dprince/pprof
Add pprof-bind-address option to main.go
2 parents ac31516 + 286c439 commit 75288c9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ build: generate fmt vet ## Build manager binary.
131131
go build -o bin/manager main.go
132132

133133
.PHONY: run
134+
run: export METRICS_PORT?=8080
135+
run: export HEALTH_PORT?=8081
136+
run: export PPROF_PORT?=8082
134137
run: manifests generate fmt vet ## Run a controller from your host.
135138
source hack/export_related_images.sh && \
136-
go run ./main.go
139+
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
137140

138141
.PHONY: docker-build
139142
docker-build: ## test ## Build docker image with the manager.

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ func main() {
6161
var metricsAddr string
6262
var enableLeaderElection bool
6363
var probeAddr string
64+
var pprofBindAddress string
6465
var enableHTTP2 bool
6566
flag.BoolVar(&enableHTTP2, "enable-http2", enableHTTP2, "If HTTP/2 should be enabled for the metrics and webhook servers.")
6667
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
6768
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
69+
flag.StringVar(&pprofBindAddress, "pprof-bind-address", "", "The address the pprof endpoint binds to. Set to empty to disable pprof.")
6870
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6971
"Enable leader election for controller manager. "+
7072
"Enabling this will ensure there is only one active controller manager.")
@@ -96,6 +98,7 @@ func main() {
9698
HealthProbeBindAddress: probeAddr,
9799
LeaderElection: enableLeaderElection,
98100
LeaderElectionID: "6cce095b.openstack.org",
101+
PprofBindAddress: pprofBindAddress,
99102
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
100103
// when the Manager ends. This requires the binary to immediately end when the
101104
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly

0 commit comments

Comments
 (0)