(cfg *config.Config)
| 42 | } |
| 43 | |
| 44 | func (p *pprofServer) Apply(cfg *config.Config) { |
| 45 | if p == nil || cfg == nil { |
| 46 | return |
| 47 | } |
| 48 | addr := strings.TrimSpace(cfg.Pprof.Addr) |
| 49 | if addr == "" { |
| 50 | addr = config.DefaultPprofAddr |
| 51 | } |
| 52 | enabled := cfg.Pprof.Enable |
| 53 | |
| 54 | p.mu.Lock() |
| 55 | currentServer := p.server |
| 56 | currentAddr := p.addr |
| 57 | p.addr = addr |
| 58 | p.enabled = enabled |
| 59 | if !enabled { |
| 60 | p.server = nil |
| 61 | p.mu.Unlock() |
| 62 | if currentServer != nil { |
| 63 | p.stopServer(currentServer, currentAddr, "disabled") |
| 64 | } |
| 65 | return |
| 66 | } |
| 67 | if currentServer != nil && currentAddr == addr { |
| 68 | p.mu.Unlock() |
| 69 | return |
| 70 | } |
| 71 | p.server = nil |
| 72 | p.mu.Unlock() |
| 73 | |
| 74 | if currentServer != nil { |
| 75 | p.stopServer(currentServer, currentAddr, "restarted") |
| 76 | } |
| 77 | |
| 78 | p.startServer(addr) |
| 79 | } |
| 80 | |
| 81 | func (p *pprofServer) Shutdown(ctx context.Context) error { |
| 82 | if p == nil { |
nothing calls this directly
no test coverage detected