From 3ee8539908d6dd6da0df35669404162fd01e23da Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 21 Feb 2019 14:27:42 +0200 Subject: [PATCH] Moved pprof server on http server --- cmd/cgr-engine/cgr-engine.go | 13 +------------ config/config_defaults.go | 2 -- config/config_json_test.go | 2 -- config/generalcfg.go | 5 +---- config/libconfig_json.go | 2 -- config/listencfg.go | 5 ----- data/conf/cgrates/cgrates.json | 2 -- utils/server.go | 1 + 8 files changed, 3 insertions(+), 29 deletions(-) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index cf5c47003..5bd69fe40 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -22,8 +22,6 @@ import ( "flag" "fmt" "log" - "net/http" - _ "net/http/pprof" "os" "os/signal" "path" @@ -1140,13 +1138,6 @@ func schedCDRsConns(internalCDRSChan chan rpcclient.RpcClientConnection, exitCha engine.SetSchedCdrsConns(cdrsConn) } -func startProfServer(adress string) { - go func() { - if err := http.ListenAndServe(adress, nil); err != nil { - utils.Logger.Err(fmt.Sprintf(" could not start HTTP server for profiling: %v", err.Error())) - } - }() -} func memProfFile(memProfPath string) bool { f, err := os.Create(memProfPath) @@ -1258,9 +1249,7 @@ func main() { lgLevel = *logLevel } utils.Logger.SetLogLevel(lgLevel) - if cfg.GeneralCfg().EnableHTTPPprof { - startProfServer(cfg.ListenCfg().HTTPPprof) - } + var loadDb engine.LoadStorage var cdrDb engine.CdrStorage var dm *engine.DataManager diff --git a/config/config_defaults.go b/config/config_defaults.go index 280f5931b..f4e61ec1d 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -51,7 +51,6 @@ const CGRATES_CFG_JSON = ` "digest_separator": ",", "digest_equal": ":", "rsr_separator": ";", - "enable_http_pprof":false, // enables the http server used for profiling }, @@ -87,7 +86,6 @@ const CGRATES_CFG_JSON = ` "rpc_json_tls" : "127.0.0.1:2022", // RPC JSON TLS listening address "rpc_gob_tls": "127.0.0.1:2023", // RPC GOB TLS listening address "http_tls": "127.0.0.1:2280", // HTTP TLS listening address - "http_pprof": "127.0.0.1:2081" // HTTP pprof server address }, diff --git a/config/config_json_test.go b/config/config_json_test.go index ef7bade77..961020489 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -61,7 +61,6 @@ func TestDfGeneralJsonCfg(t *testing.T) { Digest_separator: utils.StringPointer(","), Digest_equal: utils.StringPointer(":"), Rsr_separator: utils.StringPointer(";"), - Enable_http_pprof: utils.BoolPointer(false), } if gCfg, err := dfCgrJsonCfg.GeneralJsonCfg(); err != nil { t.Error(err) @@ -172,7 +171,6 @@ func TestDfListenJsonCfg(t *testing.T) { Rpc_json_tls: utils.StringPointer("127.0.0.1:2022"), Rpc_gob_tls: utils.StringPointer("127.0.0.1:2023"), Http_tls: utils.StringPointer("127.0.0.1:2280"), - Http_pprof: utils.StringPointer("127.0.0.1:2081"), } if cfg, err := dfCgrJsonCfg.ListenJsonCfg(); err != nil { t.Error(err) diff --git a/config/generalcfg.go b/config/generalcfg.go index 3e28e654a..07052f093 100644 --- a/config/generalcfg.go +++ b/config/generalcfg.go @@ -50,7 +50,6 @@ type GeneralCfg struct { DigestSeparator string // DigestEqual string // RsrSepatarot string // separator used to split RSRParser (by degault is used ";") - EnableHTTPPprof bool // enables the http server used for profiling } //loadFromJsonCfg loads General config from JsonCfg @@ -138,8 +137,6 @@ func (gencfg *GeneralCfg) loadFromJsonCfg(jsnGeneralCfg *GeneralJsonCfg) (err er if jsnGeneralCfg.Rsr_separator != nil { gencfg.RsrSepatarot = *jsnGeneralCfg.Rsr_separator } - if jsnGeneralCfg.Enable_http_pprof != nil { - gencfg.EnableHTTPPprof = *jsnGeneralCfg.Enable_http_pprof - } + return nil } diff --git a/config/libconfig_json.go b/config/libconfig_json.go index b7b087660..6f0575029 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -43,7 +43,6 @@ type GeneralJsonCfg struct { Digest_separator *string Digest_equal *string Rsr_separator *string - Enable_http_pprof *bool } // Listen config section @@ -54,7 +53,6 @@ type ListenJsonCfg struct { Rpc_json_tls *string Rpc_gob_tls *string Http_tls *string - Http_pprof *string } // HTTP config section diff --git a/config/listencfg.go b/config/listencfg.go index 8bc1ad426..ff3603372 100644 --- a/config/listencfg.go +++ b/config/listencfg.go @@ -26,8 +26,6 @@ type ListenCfg struct { RPCJSONTLSListen string // RPC JSON TLS listening address RPCGOBTLSListen string // RPC GOB TLS listening address HTTPTLSListen string // HTTP TLS listening address - HTTPPprof string // HTTP pprof server address - } //loadFromJsonCfg loads Database config from JsonCfg @@ -53,8 +51,5 @@ func (lstcfg *ListenCfg) loadFromJsonCfg(jsnListenCfg *ListenJsonCfg) (err error if jsnListenCfg.Http_tls != nil && *jsnListenCfg.Http_tls != "" { lstcfg.HTTPTLSListen = *jsnListenCfg.Http_tls } - if jsnListenCfg.Http_pprof != nil && *jsnListenCfg.Http_pprof != "" { - lstcfg.HTTPPprof = *jsnListenCfg.Http_pprof - } return nil } diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 3c5456815..15c4900d8 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -30,7 +30,6 @@ // "digest_separator": ",", // "digest_equal": ":", // "rsr_separator": ";", -// "enable_http_pprof":false, // enables the http server used for profiling // }, @@ -66,7 +65,6 @@ // "rpc_json_tls" : "127.0.0.1:2022", // RPC JSON TLS listening address // "rpc_gob_tls": "127.0.0.1:2023", // RPC GOB TLS listening address // "http_tls": "127.0.0.1:2280", // HTTP TLS listening address -// "http_pprof": "127.0.0.1:2081" // HTTP pprof server address // }, diff --git a/utils/server.go b/utils/server.go index 971979f17..eb7adbf49 100644 --- a/utils/server.go +++ b/utils/server.go @@ -28,6 +28,7 @@ import ( "log" "net" "net/http" + _ "net/http/pprof" "net/rpc" "net/rpc/jsonrpc" "reflect"