1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/profiling/pprof.go

27 lines
609 B
Go
Raw Normal View History

package profiling
import (
"net/http"
_ "net/http/pprof" // #nosec
"os"
"time"
"github.com/go-logr/logr"
"github.com/kyverno/kyverno/pkg/logging"
)
func Start(logger logr.Logger, address string) {
logger.Info("Enable profiling, see details at https://github.com/kyverno/kyverno/wiki/Profiling-Kyverno-on-Kubernetes")
go func() {
s := http.Server{
Addr: address,
ErrorLog: logging.StdLogger(logger, ""),
ReadHeaderTimeout: 30 * time.Second,
}
if err := s.ListenAndServe(); err != nil {
logger.Error(err, "failed to enable profiling")
os.Exit(1)
}
}()
}