Skip to content

Commit a09f892

Browse files
Merge pull request #336 from dprince/pprof
Add pprof-bind-address option to main.go
2 parents 962524e + ff6619c commit a09f892

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,12 @@ build: generate fmt vet ## Build manager binary.
144144
.PHONY: run
145145
run: export METRICS_PORT?=8080
146146
run: export HEALTH_PORT?=8081
147+
run: export PPROF_PORT?=8082
147148
run: export OPERATOR_TEMPLATES=./templates/
148149
run: export ENABLE_WEBHOOKS?=false
149150
run: manifests generate fmt vet ## Run a controller from your host.
150151
/bin/bash hack/clean_local_webhook.sh
151-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)"
152+
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
152153

153154
.PHONY: docker-build
154155
docker-build: test ## Build docker image with the manager.
@@ -376,6 +377,7 @@ SKIP_CERT ?=false
376377
.PHONY: run-with-webhook
377378
run-with-webhook: export METRICS_PORT?=8080
378379
run-with-webhook: export HEALTH_PORT?=8081
380+
run-with-webhook: export PPROF_PORT?=8082
379381
run-with-webhook: manifests generate fmt vet ## Run a controller from your host.
380382
/bin/bash hack/run_with_local_webhook.sh
381383

hack/run_with_local_webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,4 @@ else
176176
oc scale --replicas=0 -n openstack-operators deploy/mariadb-operator-controller-manager
177177
fi
178178

179-
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}"
179+
go run ./main.go -metrics-bind-address ":${METRICS_PORT}" -health-probe-bind-address ":${HEALTH_PORT}" -pprof-bind-address ":${PPROF_PORT}"

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.")
@@ -91,6 +93,7 @@ func main() {
9193
HealthProbeBindAddress: probeAddr,
9294
LeaderElection: enableLeaderElection,
9395
LeaderElectionID: "7c2a6c6b.openstack.org",
96+
PprofBindAddress: pprofBindAddress,
9497
WebhookServer: webhook.NewServer(
9598
webhook.Options{
9699
Port: 9443,

0 commit comments

Comments
 (0)