mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added checkConfig flag at cgr-engine
This commit is contained in:
@@ -44,6 +44,7 @@ var (
|
||||
cgrEngineFlags = flag.NewFlagSet("cgr-engine", flag.ContinueOnError)
|
||||
cfgPath = cgrEngineFlags.String("config_path", utils.CONFIG_PATH, "Configuration directory path.")
|
||||
version = cgrEngineFlags.Bool("version", false, "Prints the application version.")
|
||||
checkConfig = cgrEngineFlags.Bool("check_config", false, "Verify the config without starting the engine")
|
||||
pidFile = cgrEngineFlags.String("pid", "", "Write pid file")
|
||||
httpPprofPath = cgrEngineFlags.String("httprof_path", "", "http address used for program profiling")
|
||||
cpuProfDir = cgrEngineFlags.String("cpuprof_dir", "", "write cpu profile to files")
|
||||
@@ -367,6 +368,12 @@ func main() {
|
||||
if *nodeID != utils.EmptyString {
|
||||
cfg.GeneralCfg().NodeID = *nodeID
|
||||
}
|
||||
if *checkConfig {
|
||||
if err := cfg.CheckConfigSanity(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
config.SetCgrConfig(cfg) // Share the config object
|
||||
|
||||
// init syslog
|
||||
|
||||
@@ -26,6 +26,11 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// Exported in cgr-engine
|
||||
func (cfg *CGRConfig) CheckConfigSanity() error {
|
||||
return cfg.checkConfigSanity()
|
||||
}
|
||||
|
||||
func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
// Rater checks
|
||||
if cfg.ralsCfg.Enabled {
|
||||
@@ -298,7 +303,7 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
return fmt.Errorf("<%s> not enabled but requested by <%s> HTTPAgent Template.", utils.SessionS, httpAgentCfg.ID)
|
||||
}
|
||||
if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) {
|
||||
return fmt.Errorf("HTTPAgent Templae with ID <%s> has connection with id: <%s> not defined", httpAgentCfg.ID, connID)
|
||||
return fmt.Errorf("<%s> Template with ID <%s> has connection with id: <%s> not defined", utils.HTTPAgent, httpAgentCfg.ID, connID)
|
||||
}
|
||||
}
|
||||
if !utils.SliceHasMember([]string{utils.MetaUrl, utils.MetaXml}, httpAgentCfg.RequestPayload) {
|
||||
@@ -475,7 +480,7 @@ func (cfg *CGRConfig) checkConfigSanity() error {
|
||||
if cfg.dispatcherSCfg.Enabled {
|
||||
for _, connID := range cfg.dispatcherSCfg.AttributeSConns {
|
||||
if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.attributeSCfg.Enabled {
|
||||
return fmt.Errorf("<%s> not enabled but requested by <%s> component", utils.AttributeS, utils.DispatcherS)
|
||||
return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.AttributeS, utils.DispatcherS)
|
||||
}
|
||||
if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) {
|
||||
return fmt.Errorf("<%s> Connection with id: <%s> not defined", utils.DispatcherS, connID)
|
||||
|
||||
Reference in New Issue
Block a user