-
Notifications
You must be signed in to change notification settings - Fork 591
/
servers.go
36 lines (31 loc) · 960 Bytes
/
servers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package rootcmd
import (
"context"
"github.com/go-logr/logr"
"github.com/kong/kubernetes-ingress-controller/v3/internal/diagnostics"
"github.com/kong/kubernetes-ingress-controller/v3/internal/manager"
)
// StartDiagnosticsServer starts a goroutine that handles requests for the diagnostics server.
func StartDiagnosticsServer(
ctx context.Context,
port int,
c *manager.Config,
logger logr.Logger,
) (diagnostics.Server, error) {
if !c.EnableProfiling && !c.EnableConfigDumps {
logger.Info("Diagnostics server disabled")
return diagnostics.Server{}, nil
}
logger.Info("Starting diagnostics server")
s := diagnostics.NewServer(logger, diagnostics.ServerConfig{
ProfilingEnabled: c.EnableProfiling,
ConfigDumpsEnabled: c.EnableConfigDumps,
DumpSensitiveConfig: c.DumpSensitiveConfig,
})
go func() {
if err := s.Listen(ctx, port); err != nil {
logger.Error(err, "Unable to start diagnostics server")
}
}()
return s, nil
}