Skip to content

Commit

Permalink
add net/http/pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
dubuqingfeng committed Aug 21, 2019
1 parent 466b9b6 commit 752b00d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config.yaml
.idea
vendor
config.*.yaml
*.log
*.log.*
10 changes: 10 additions & 0 deletions cmd/height/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package height
import (
"github.com/dubuqingfeng/stratum-server-monitor/manager"
"github.com/dubuqingfeng/stratum-server-monitor/utils"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"net/http"
_ "net/http/pprof"
"time"
)

Expand All @@ -19,6 +22,13 @@ func NewHeightFetcherCommand() *cobra.Command {
func stratumServerHeightFetch(cmd *cobra.Command, args []string) {
utils.ConfigLocalFilesystemLogger("./logs/", "fetcher.log", 7*time.Hour*24, time.Second*20)
// Initialization storage
if utils.Config.Debug {
go func() {
if err := http.ListenAndServe("0.0.0.0:8080", nil); err != nil {
log.Error(err)
}
}()
}
ssManager := manager.Manager{}
ssManager.Run()
quit := make(chan bool)
Expand Down
1 change: 1 addition & 0 deletions fetchers/HeightFetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func (p *PoolHeightFetcher) handleNotifyRes(resp interface{}) {
p.SendNotification(notification)
log.WithField("endpoint", p.Address).Info(fmt.Sprintf("height: %d, old height: %d", height, p.Height))
}
// mutex
p.Height = height
}

Expand Down
1 change: 1 addition & 0 deletions utils/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "github.com/jinzhu/configor"

var Config = struct {
Name string `default:"app_name"`
Debug bool
MonitorName string `default:"ss-monitor"`
StratumServerConfigDatabaseTablePrefix string
GlobalDatabase MySQLDB
Expand Down

0 comments on commit 752b00d

Please sign in to comment.