From 1578ecca9836016f74a763c1646fa1eab21dc3cb Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 16 Jun 2023 11:52:42 -0400 Subject: [PATCH] support for pprof endpoint --- controller/config/config.go | 5 +++-- controller/controller.go | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/controller/config/config.go b/controller/config/config.go index 1f09d0c5..396bd3d1 100644 --- a/controller/config/config.go +++ b/controller/config/config.go @@ -34,8 +34,9 @@ type Config struct { } type AdminConfig struct { - Secrets []string `cf:"+secret"` - TouLink string + Secrets []string `cf:"+secret"` + TouLink string + ProfileEndpoint string } type EndpointConfig struct { diff --git a/controller/controller.go b/controller/controller.go index 712d234f..a5974e7f 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -2,11 +2,13 @@ package controller import ( "context" - "github.com/openziti/zrok/controller/config" "github.com/openziti/zrok/controller/limits" "github.com/openziti/zrok/controller/metrics" "github.com/sirupsen/logrus" + "log" + "net/http" + _ "net/http/pprof" "github.com/go-openapi/loads" influxdb2 "github.com/influxdata/influxdb-client-go/v2" @@ -26,6 +28,12 @@ var limitsAgent *limits.Agent func Run(inCfg *config.Config) error { cfg = inCfg + if cfg.Admin != nil && cfg.Admin.ProfileEndpoint != "" { + go func() { + log.Println(http.ListenAndServe(cfg.Admin.ProfileEndpoint, nil)) + }() + } + swaggerSpec, err := loads.Embedded(rest_server_zrok.SwaggerJSON, rest_server_zrok.FlatSwaggerJSON) if err != nil { return errors.Wrap(err, "error loading embedded swagger spec")