Refactor HTTP profiling and flag handling

- hardcode the base path for profiling endpoints to '/debug/pprof/'
- change profiling flag 'httprof_path' to boolean 'http_pprof'
  (because of the above)
- remove redundant profiling endpoint registrations (handled by pprof.Index)
- move profiling registration log after actual registration
- make profiling registration log more descriptive
- use utils.Logger instead of log.Print for the log mentioned above
- refactor flags test into a table test (adding also verification for default
  flag values)
- change 'scheduledShutdown' flag type from string to time.Duration (to avoid
  unnecessary time parsing)
- revise flags usage descriptions
- rename flag 'singlecpu' to 'singleCPU'
- switch to 'ExitOnError' for flag parsing to simplify error handling and
  automatically handle 'ErrHelp' by exiting with status 0 when help is
  requested and status 2 for other parsing errors. Before the following error
  log would have been received:
  '<InitS> error received: <flag: help requested>, exiting!'
- update cgr-engine documentation
This commit is contained in:
ionutboangiu
2024-07-17 23:47:06 +03:00
committed by Dan Christian Bogos
parent 9eeee38824
commit 958aa267cf
6 changed files with 183 additions and 155 deletions

View File

@@ -9,40 +9,41 @@ Customisable through the use of *json* :ref:`JSON configuration <configuration>`
Able to read the configuration from either a local directory of *.json* files with an unlimited number of subfolders (ordered alphabetically) or a list of http paths (separated by ";").
::
$ cgr-engine -help
Usage of cgr-engine:
-check_config
Verify the config without starting the engine
-config_path string
Configuration directory path. (default "/etc/cgrates/")
Configuration directory path (default "/etc/cgrates/")
-cpuprof_dir string
write cpu profile to files
-httprof_path string
http address used for program profiling
Directory for CPU profiles
-http_pprof
Enable HTTP pprof profiling
-log_level int
Log level (0-emergency to 7-debug) (default -1)
Log level (0=emergency to 7=debug) (default -1)
-logger string
logger <*syslog|*stdout>
Logger type <*syslog|*stdout>
-memprof_dir string
write memory profile to file
Directory for memory profiles
-memprof_interval duration
Time between memory profile saves (default 5s)
Interval between memory profile saves (default 5s)
-memprof_nrfiles int
Number of memory profile to write (default 1)
Number of memory profiles to keep (most recent) (default 1)
-node_id string
The node ID of the engine
Node ID of the engine
-pid string
Write pid file
Path to write the PID file
-preload string
LoaderIDs used to load the data before the engine starts
-scheduled_shutdown string
shutdown the engine after this duration
Loader IDs used to load data before engine starts
-print_config
Print configuration object in JSON format
-scheduled_shutdown duration
Shutdown the engine after the specified duration
-singlecpu
Run on single CPU core
Run on a single CPU core
-version
Prints the application version.
Print application version and exit
@@ -81,4 +82,4 @@ The components from the diagram can be found documented in the links bellow:
caches
datadb
stordb