@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
"flag"
22
22
"math/rand"
23
+ "net/http"
23
24
"os"
24
25
"time"
25
26
55
56
// flags.
56
57
metricsBindAddr string
57
58
enableLeaderElection bool
59
+ profilerAddress string
58
60
syncPeriod time.Duration
59
61
concurrency int
60
62
healthAddr string
@@ -84,6 +86,8 @@ func initFlags(fs *pflag.FlagSet) {
84
86
"The number of docker machines to process simultaneously" )
85
87
fs .BoolVar (& enableLeaderElection , "leader-elect" , false ,
86
88
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager." )
89
+ fs .StringVar (& profilerAddress , "profiler-address" , "" ,
90
+ "Bind address to expose the pprof profiler (e.g. localhost:6060)" )
87
91
fs .DurationVar (& syncPeriod , "sync-period" , 10 * time .Minute ,
88
92
"The minimum interval at which watched resources are reconciled (e.g. 15m)" )
89
93
fs .StringVar (& healthAddr , "health-addr" , ":9440" ,
@@ -106,6 +110,13 @@ func main() {
106
110
107
111
ctrl .SetLogger (klogr .New ())
108
112
113
+ if profilerAddress != "" {
114
+ klog .Infof ("Profiler listening for requests at %s" , profilerAddress )
115
+ go func () {
116
+ klog .Info (http .ListenAndServe (profilerAddress , nil ))
117
+ }()
118
+ }
119
+
109
120
restConfig := ctrl .GetConfigOrDie ()
110
121
restConfig .UserAgent = remote .DefaultClusterAPIUserAgent ("cluster-api-docker-controller-manager" )
111
122
mgr , err := ctrl .NewManager (restConfig , ctrl.Options {
0 commit comments