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) {
|
func (c *Controller) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
c.initController()
|
c.initController()
|
||||||
|
|
||||||
wg.Add(4)
|
wg.Add(5)
|
||||||
go c.runPodInformer(stopCh, wg)
|
go c.runPodInformer(stopCh, wg)
|
||||||
go c.runPostgresqlInformer(stopCh, wg)
|
go c.runPostgresqlInformer(stopCh, wg)
|
||||||
go c.podEventsDispatcher(stopCh, wg)
|
go c.podEventsDispatcher(stopCh, wg)
|
||||||
go c.clusterResync(stopCh, wg)
|
go c.clusterResync(stopCh, wg)
|
||||||
|
go c.RunAPIServer(stopCh, wg)
|
||||||
|
|
||||||
for i := range c.clusterEventQueues {
|
for i := range c.clusterEventQueues {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,24 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/pprof"
|
||||||
"sync"
|
"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()
|
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{
|
server := http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", c.opConfig.Port),
|
Addr: fmt.Sprintf(":%d", c.opConfig.APIPort),
|
||||||
Handler: c,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
@ -26,7 +33,8 @@ func (c *Controller) restAPIServer(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
c.logger.Infof("listening on %s", server.Addr)
|
c.logger.Infof("listening on %s", server.Addr)
|
||||||
|
|
||||||
<-stopCh
|
<-stopCh
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
|
ctx, _ := context.WithCancel(context.Background())
|
||||||
server.Shutdown(ctx)
|
server.Shutdown(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ type Config struct {
|
||||||
MasterDNSNameFormat stringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"`
|
MasterDNSNameFormat stringTemplate `name:"master_dns_name_format" default:"{cluster}.{team}.{hostedzone}"`
|
||||||
ReplicaDNSNameFormat stringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
ReplicaDNSNameFormat stringTemplate `name:"replica_dns_name_format" default:"{cluster}-repl.{team}.{hostedzone}"`
|
||||||
Workers uint32 `name:"workers" default:"4"`
|
Workers uint32 `name:"workers" default:"4"`
|
||||||
Port uint32 `name:"port" default:"80"`
|
APIPort int `name:"api_port" default:"8080"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) MustMarshal() string {
|
func (c Config) MustMarshal() string {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue