Skip to content

Commit

Permalink
prometheus reporter startup failure is not forced to panic, but outpu…
Browse files Browse the repository at this point in the history
…t log
  • Loading branch information
chgz committed Jun 21, 2021
1 parent 3b3a670 commit fca4172
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions metrics/prometheus_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package metrics

import (
"fmt"
"log"
"github.com/topfreegames/pitaya/logger"
"net/http"
"sync"

Expand Down Expand Up @@ -301,7 +301,10 @@ func GetPrometheusReporter(
prometheusReporter.registerMetrics(constLabels, additionalLabels, spec)
http.Handle("/metrics", promhttp.Handler())
go (func() {
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
err = http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
if err != nil {
logger.Log.Error("prometheus reporter serve start failed, err: ", err)
}
})()
})

Expand Down

0 comments on commit fca4172

Please sign in to comment.