support for pprof endpoint

This commit is contained in:
Michael Quigley 2023-06-16 11:52:42 -04:00
parent 4420254c5c
commit 1578ecca98
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 12 additions and 3 deletions

View File

@ -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 {

View File

@ -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")