add pprof
This commit is contained in:
parent
54defa8070
commit
102b72e8bf
|
|
@ -171,11 +171,12 @@ func (c *Controller) initController() {
|
|||
func (c *Controller) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||
c.initController()
|
||||
|
||||
wg.Add(4)
|
||||
wg.Add(5)
|
||||
go c.runPodInformer(stopCh, wg)
|
||||
go c.runPostgresqlInformer(stopCh, wg)
|
||||
go c.podEventsDispatcher(stopCh, wg)
|
||||
go c.clusterResync(stopCh, wg)
|
||||
go c.RunAPIServer(stopCh, wg)
|
||||
|
||||
for i := range c.clusterEventQueues {
|
||||
wg.Add(1)
|
||||
|
|
@ -195,4 +196,4 @@ func (c *Controller) runPostgresqlInformer(stopCh <-chan struct{}, wg *sync.Wait
|
|||
defer wg.Done()
|
||||
|
||||
c.postgresqlInformer.Run(stopCh)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,24 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *Controller) restAPIServer(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||
func (c *Controller) RunAPIServer(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
wg.Add(1)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
|
||||
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
|
||||
server := http.Server{
|
||||
Addr: fmt.Sprintf(":%d", c.opConfig.Port),
|
||||
Handler: c,
|
||||
Addr: fmt.Sprintf(":%d", c.opConfig.APIPort),
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
|
@ -26,7 +33,8 @@ func (c *Controller) restAPIServer(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
|||
c.logger.Infof("listening on %s", server.Addr)
|
||||
|
||||
<-stopCh
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
|
||||
ctx, _ := context.WithCancel(context.Background())
|
||||
server.Shutdown(ctx)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ type Config struct {
|
|||
MasterDNSNameFormat stringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"`
|
||||
ReplicaDNSNameFormat stringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
||||
Workers uint32 `name:"workers" default:"4"`
|
||||
Port uint32 `name:"port" default:"80"`
|
||||
APIPort int `name:"api_port" default:"8080"`
|
||||
}
|
||||
|
||||
func (c Config) MustMarshal() string {
|
||||
|
|
|
|||
Loading…
Reference in New Issue