forked from TrueCloudLab/distribution
Merge pull request #3895 from pluralsh/bug-fix-5001-server-rebase
Fix the issue that the debug server with port 5001 run twice
This commit is contained in:
commit
8900e90699
1 changed files with 24 additions and 18 deletions
|
@ -100,29 +100,12 @@ var ServeCmd = &cobra.Command{
|
|||
cmd.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if config.HTTP.Debug.Addr != "" {
|
||||
go func(addr string) {
|
||||
logrus.Infof("debug server listening %v", addr)
|
||||
if err := http.ListenAndServe(addr, nil); err != nil {
|
||||
logrus.Fatalf("error listening on debug interface: %v", err)
|
||||
}
|
||||
}(config.HTTP.Debug.Addr)
|
||||
}
|
||||
|
||||
registry, err := NewRegistry(ctx, config)
|
||||
if err != nil {
|
||||
logrus.Fatalln(err)
|
||||
}
|
||||
|
||||
if config.HTTP.Debug.Prometheus.Enabled {
|
||||
path := config.HTTP.Debug.Prometheus.Path
|
||||
if path == "" {
|
||||
path = "/metrics"
|
||||
}
|
||||
logrus.Info("providing prometheus metrics on ", path)
|
||||
http.Handle(path, metrics.Handler())
|
||||
}
|
||||
configureDebugServer(config)
|
||||
|
||||
if err = registry.ListenAndServe(); err != nil {
|
||||
logrus.Fatalln(err)
|
||||
|
@ -318,6 +301,29 @@ func (registry *Registry) ListenAndServe() error {
|
|||
}
|
||||
}
|
||||
|
||||
func configureDebugServer(config *configuration.Configuration) {
|
||||
if config.HTTP.Debug.Addr != "" {
|
||||
go func(addr string) {
|
||||
logrus.Infof("debug server listening %v", addr)
|
||||
if err := http.ListenAndServe(addr, nil); err != nil {
|
||||
logrus.Fatalf("error listening on debug interface: %v", err)
|
||||
}
|
||||
}(config.HTTP.Debug.Addr)
|
||||
configurePrometheus(config)
|
||||
}
|
||||
}
|
||||
|
||||
func configurePrometheus(config *configuration.Configuration) {
|
||||
if config.HTTP.Debug.Prometheus.Enabled {
|
||||
path := config.HTTP.Debug.Prometheus.Path
|
||||
if path == "" {
|
||||
path = "/metrics"
|
||||
}
|
||||
logrus.Info("providing prometheus metrics on ", path)
|
||||
http.Handle(path, metrics.Handler())
|
||||
}
|
||||
}
|
||||
|
||||
func configureReporting(app *handlers.App) http.Handler {
|
||||
var handler http.Handler = app
|
||||
|
||||
|
|
Loading…
Reference in a new issue