diff --git a/agent.go b/agent.go index 8726ea2e..bf963fc4 100644 --- a/agent.go +++ b/agent.go @@ -231,7 +231,7 @@ const ( // DefaultEdgeSleepInterval is the default interval after which the agent will close the tunnel if no activity. DefaultEdgeSleepInterval = "5m" // DefaultConfigCheckInterval is the default interval used to check if node config changed - DefaultConfigCheckInterval = "5s" + DefaultConfigCheckInterval = "300s" // SupportedDockerAPIVersion is the minimum Docker API version supported by the agent. SupportedDockerAPIVersion = "1.24" // DefaultClusterProbeTimeout is the default member list ping probe timeout. diff --git a/edge/edge.go b/edge/edge.go index 8c954796..683c099a 100644 --- a/edge/edge.go +++ b/edge/edge.go @@ -151,15 +151,15 @@ func (manager *Manager) startEdgeBackgroundProcessOnDocker(runtimeCheckFrequency return err } - go func() { - ticker := time.NewTicker(runtimeCheckFrequency) - for range ticker.C { - err := manager.checkDockerRuntimeConfig() - if err != nil { - log.Printf("[ERROR] [edge] [message: an error occurred during Docker runtime configuration check] [error: %s]", err) - } - } - }() + // go func() { + // ticker := time.NewTicker(runtimeCheckFrequency) + // for range ticker.C { + // err := manager.checkDockerRuntimeConfig() + // if err != nil { + // log.Printf("[ERROR] [edge] [message: an error occurred during Docker runtime configuration check] [error: %s]", err) + // } + // } + // }() return nil } diff --git a/http/handler/handler.go b/http/handler/handler.go index 49d7e620..501c7f4b 100644 --- a/http/handler/handler.go +++ b/http/handler/handler.go @@ -2,7 +2,9 @@ package handler import ( "net/http" + "net/http/pprof" "regexp" + "runtime" "strconv" "strings" @@ -58,6 +60,11 @@ type Config struct { ContainerPlatform agent.ContainerPlatform } +func init() { + runtime.SetBlockProfileRate(1) + runtime.SetMutexProfileFraction(1) +} + var dockerAPIVersionRegexp = regexp.MustCompile(`(/v[0-9]\.[0-9]*)?`) // NewHandler returns a pointer to a Handler. @@ -101,6 +108,12 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, request *http.Request) { rw.Header().Set(agent.HTTPResponseAgentPlatform, strconv.Itoa(int(agentPlatformIdentifier))) switch { + case strings.HasPrefix(request.URL.Path, "/debug/pprof/profile"): + pprof.Profile(rw, request) + case strings.HasPrefix(request.URL.Path, "/debug/pprof/trace"): + pprof.Trace(rw, request) + case strings.HasPrefix(request.URL.Path, "/debug/pprof"): + pprof.Index(rw, request) case strings.HasPrefix(request.URL.Path, "/v1"): h.ServeHTTPV1(rw, request) case strings.HasPrefix(request.URL.Path, "/v2"):