|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
import (
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
+ "net/http"
|
|
|
_ "net/http/pprof"
|
|
|
"sparrow/pkg/rpcs"
|
|
|
"sparrow/pkg/server"
|
|
@@ -11,15 +12,7 @@ var deviceOnlineCount prometheus.Gauge
|
|
|
var deviceMessageCount *prometheus.CounterVec
|
|
|
|
|
|
func main() {
|
|
|
-
|
|
|
- //go func() {
|
|
|
- // pprofPort := "6060"
|
|
|
- // server.Log.Infof("pprof server started at :%s/debug/pprof", pprofPort)
|
|
|
- // if err := http.ListenAndServe(":"+pprofPort, nil); err != nil {
|
|
|
- // server.Log.Errorf("pprof server failed: %v", err)
|
|
|
- // }
|
|
|
- //}()
|
|
|
-
|
|
|
+
|
|
|
// init server
|
|
|
err := server.Init(rpcs.MQTTAccessName)
|
|
|
if err != nil {
|
|
@@ -64,6 +57,15 @@ func main() {
|
|
|
server.RegisterMetric(deviceOnlineMetric, recvMessageCount)
|
|
|
deviceOnlineCount = deviceOnlineMetric.MetricCollector.(prometheus.Gauge)
|
|
|
deviceMessageCount = recvMessageCount.MetricCollector.(*prometheus.CounterVec)
|
|
|
+
|
|
|
+ go func() {
|
|
|
+ pprofPort := "6060"
|
|
|
+ server.Log.Infof("pprof server started at :%s/debug/pprof", pprofPort)
|
|
|
+ if err := http.ListenAndServe(":"+pprofPort, nil); err != nil {
|
|
|
+ server.Log.Errorf("pprof server failed: %v", err)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
// start to run
|
|
|
err = server.Run()
|
|
|
if err != nil {
|