mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Added config option to enable pprof (#253)
* Added config option to enable pprof * fixed typo in Makefile
This commit is contained in:
12
Makefile
12
Makefile
@@ -2,6 +2,8 @@ LDFLAGS = -ldflags "-w -s"
|
||||
GCTPKG = github.com/thrasher-/gocryptotrader
|
||||
LINTPKG = github.com/golangci/golangci-lint/cmd/golangci-lint@v1.15.0
|
||||
LINTBIN = $(GOPATH)/bin/golangci-lint
|
||||
GCTLISTENPORT=9050
|
||||
GCTPROFILERLISTENPORT=8085
|
||||
|
||||
get:
|
||||
GO111MODULE=on go get $(GCTPKG)
|
||||
@@ -29,4 +31,12 @@ update_deps:
|
||||
GO111MODULE=on go mod verify
|
||||
GO111MODULE=on go mod tidy
|
||||
rm -rf vendor
|
||||
GO111MODULE=on go mod vendor
|
||||
GO111MODULE=on go mod vendor
|
||||
|
||||
.PHONY: profile_heap
|
||||
profile_heap:
|
||||
go tool pprof -http "localhost:$(GCTPROFILERLISTENPORT)" 'http://localhost:$(GCTLISTENPORT)/debug/pprof/heap'
|
||||
|
||||
.PHONY: profile_cpu
|
||||
profile_cpu:
|
||||
go tool pprof -http "localhost:$(GCTPROFILERLISTENPORT)" 'http://localhost:$(GCTLISTENPORT)/debug/pprof/profile'
|
||||
@@ -104,6 +104,7 @@ type Config struct {
|
||||
EncryptConfig int `json:"encryptConfig"`
|
||||
GlobalHTTPTimeout time.Duration `json:"globalHTTPTimeout"`
|
||||
Logging log.Logging `json:"logging"`
|
||||
Profiler ProfilerConfig `json:"profiler"`
|
||||
Currency CurrencyConfig `json:"currencyConfig"`
|
||||
Communications CommunicationsConfig `json:"communications"`
|
||||
Portfolio portfolio.Base `json:"portfolioAddresses"`
|
||||
@@ -118,6 +119,10 @@ type Config struct {
|
||||
SMS *SMSGlobalConfig `json:"smsGlobal,omitempty"`
|
||||
}
|
||||
|
||||
type ProfilerConfig struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
}
|
||||
|
||||
// ExchangeConfig holds all the information needed for each enabled Exchange.
|
||||
type ExchangeConfig struct {
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"level": "DEBUG|WARN|INFO|ERROR|FATAL",
|
||||
"rotate": false
|
||||
},
|
||||
"profiler": {
|
||||
"enabled": false
|
||||
},
|
||||
"currencyConfig": {
|
||||
"forexProviders": [
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
|
||||
_ "net/http/pprof"
|
||||
)
|
||||
|
||||
// RESTLogger logs the requests internally
|
||||
@@ -114,6 +116,12 @@ func NewRouter() *mux.Router {
|
||||
Name(route.Name).
|
||||
Handler(RESTLogger(route.HandlerFunc, route.Name))
|
||||
}
|
||||
|
||||
if bot.config.Profiler.Enabled {
|
||||
log.Debugln("Profiler enabled")
|
||||
router.PathPrefix("/debug").Handler(http.DefaultServeMux)
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
|
||||
3
testdata/configtest.json
vendored
3
testdata/configtest.json
vendored
@@ -9,6 +9,9 @@
|
||||
"level": "DEBUG|WARN|INFO|ERROR|FATAL",
|
||||
"rotate": true
|
||||
},
|
||||
"profiler": {
|
||||
"enabled": false
|
||||
},
|
||||
"currencyConfig": {
|
||||
"forexProviders": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user