mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-09 20:43:57 +01:00
35 lines
713 B
Go
35 lines
713 B
Go
package nebula
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/slackhq/nebula/config"
|
|
)
|
|
|
|
func startHttp(l *logrus.Logger, c *config.C, statsHandler statsHandlerFunc, listen string) (f func(), err error) {
|
|
if listen == "" {
|
|
return nil, nil
|
|
}
|
|
|
|
var statsPath string
|
|
if statsHandler != nil {
|
|
statsPath = c.GetString("stats.path", "")
|
|
if statsPath == "" {
|
|
return nil, fmt.Errorf("stats.path should not be empty")
|
|
}
|
|
}
|
|
|
|
f = func() {
|
|
l.Infof("Go pprof handler listening on %s at /debug/pprof", listen)
|
|
if statsHandler != nil {
|
|
http.Handle(statsPath, statsHandler(listen, statsPath))
|
|
}
|
|
l.Fatal(http.ListenAndServe(listen, nil))
|
|
}
|
|
|
|
return f, err
|
|
}
|