mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Remove redundant http_pprof cgr-engine flag
runtime profiling is now configurable within the http cfg section and is enabled by default
This commit is contained in:
committed by
Dan Christian Bogos
parent
435ba54743
commit
b0758d082d
@@ -54,7 +54,6 @@ var (
|
|||||||
version = cgrEngineFlags.Bool(utils.VersionCgr, false, "Print application version and exit")
|
version = cgrEngineFlags.Bool(utils.VersionCgr, false, "Print application version and exit")
|
||||||
printConfig = cgrEngineFlags.Bool(utils.PrintCfgCgr, false, "Print configuration object in JSON format")
|
printConfig = cgrEngineFlags.Bool(utils.PrintCfgCgr, false, "Print configuration object in JSON format")
|
||||||
pidFile = cgrEngineFlags.String(utils.PidCgr, utils.EmptyString, "Path to write the PID file")
|
pidFile = cgrEngineFlags.String(utils.PidCgr, utils.EmptyString, "Path to write the PID file")
|
||||||
httpPprof = cgrEngineFlags.Bool(utils.HttpPprofCgr, false, "Enable HTTP pprof profiling")
|
|
||||||
cpuProfDir = cgrEngineFlags.String(utils.CpuProfDirCgr, utils.EmptyString, "Directory for CPU profiles")
|
cpuProfDir = cgrEngineFlags.String(utils.CpuProfDirCgr, utils.EmptyString, "Directory for CPU profiles")
|
||||||
memProfDir = cgrEngineFlags.String(utils.MemProfDirCgr, utils.EmptyString, "Directory for memory profiles")
|
memProfDir = cgrEngineFlags.String(utils.MemProfDirCgr, utils.EmptyString, "Directory for memory profiles")
|
||||||
memProfInterval = cgrEngineFlags.Duration(utils.MemProfIntervalCgr, 15*time.Second, "Interval between memory profile saves")
|
memProfInterval = cgrEngineFlags.Duration(utils.MemProfIntervalCgr, 15*time.Second, "Interval between memory profile saves")
|
||||||
@@ -548,10 +547,6 @@ func main() {
|
|||||||
if cfg.ConfigSCfg().Enabled {
|
if cfg.ConfigSCfg().Enabled {
|
||||||
server.RegisterHttpFunc(cfg.ConfigSCfg().URL, config.HandlerConfigS)
|
server.RegisterHttpFunc(cfg.ConfigSCfg().URL, config.HandlerConfigS)
|
||||||
}
|
}
|
||||||
if *httpPprof {
|
|
||||||
server.RegisterProfiler()
|
|
||||||
utils.Logger.Info("<HTTP> registered profiling endpoints at '/debug/pprof/'")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define internal connections via channels
|
// Define internal connections via channels
|
||||||
filterSChan := make(chan *engine.FilterS, 1)
|
filterSChan := make(chan *engine.FilterS, 1)
|
||||||
|
|||||||
@@ -63,13 +63,6 @@ func TestCgrEngineFlags(t *testing.T) {
|
|||||||
defaultVal: "",
|
defaultVal: "",
|
||||||
want: "/run/cgrates/cgrates.pid",
|
want: "/run/cgrates/cgrates.pid",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "httpPprof",
|
|
||||||
flags: []string{"-http_pprof"},
|
|
||||||
flagVar: httpPprof,
|
|
||||||
defaultVal: false,
|
|
||||||
want: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "cpuProfDir",
|
name: "cpuProfDir",
|
||||||
flags: []string{"-cpuprof_dir", "/tmp/profiling"},
|
flags: []string{"-cpuprof_dir", "/tmp/profiling"},
|
||||||
|
|||||||
@@ -188,19 +188,6 @@ func (s *Server) handleRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
io.Copy(w, res)
|
io.Copy(w, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerProfiler(mux *http.ServeMux) {
|
|
||||||
mux.HandleFunc("/debug/pprof/", pprof.Index)
|
|
||||||
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
|
||||||
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
|
||||||
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
|
||||||
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) RegisterProfiler() {
|
|
||||||
registerProfiler(s.httpMux)
|
|
||||||
registerProfiler(s.httpsMux)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) ServeHTTP(addr, jsonRPCURL, wsRPCURL, promURL, pprofPath string, useBasicAuth bool,
|
func (s *Server) ServeHTTP(addr, jsonRPCURL, wsRPCURL, promURL, pprofPath string, useBasicAuth bool,
|
||||||
userList map[string]string, shdChan *utils.SyncedChan) {
|
userList map[string]string, shdChan *utils.SyncedChan) {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
|
|||||||
@@ -95,17 +95,6 @@ func TestRegisterHttpFunc(t *testing.T) {
|
|||||||
rcv.StopBiRPC()
|
rcv.StopBiRPC()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterProfiler(t *testing.T) {
|
|
||||||
cfgDflt := config.NewDefaultCGRConfig()
|
|
||||||
cfgDflt.CoreSCfg().CapsStatsInterval = 1
|
|
||||||
caps := engine.NewCaps(0, utils.MetaBusy)
|
|
||||||
rcv := NewServer(caps)
|
|
||||||
|
|
||||||
rcv.RegisterProfiler()
|
|
||||||
|
|
||||||
rcv.StopBiRPC()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHandleRequestCORSHeaders(t *testing.T) {
|
func TestHandleRequestCORSHeaders(t *testing.T) {
|
||||||
caps := engine.NewCaps(0, utils.MetaBusy)
|
caps := engine.NewCaps(0, utils.MetaBusy)
|
||||||
rcv := NewServer(caps)
|
rcv := NewServer(caps)
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ Able to read the configuration from either a local directory of *.json* files w
|
|||||||
Configuration directory path (default "/etc/cgrates/")
|
Configuration directory path (default "/etc/cgrates/")
|
||||||
-cpuprof_dir string
|
-cpuprof_dir string
|
||||||
Directory for CPU profiles
|
Directory for CPU profiles
|
||||||
-http_pprof
|
|
||||||
Enable HTTP pprof profiling
|
|
||||||
-log_level int
|
-log_level int
|
||||||
Log level (0=emergency to 7=debug) (default -1)
|
Log level (0=emergency to 7=debug) (default -1)
|
||||||
-logger string
|
-logger string
|
||||||
|
|||||||
Reference in New Issue
Block a user