diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 763a36614..115b2add8 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -118,6 +118,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { return err } tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account) + engine.Logger.Debug("Add balance before getAccount") if _, err := self.AccountDb.GetAccount(tag); err != nil { // create user balance if not exists account := &engine.Account{ @@ -128,6 +129,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { return err } } + engine.Logger.Debug("Add balance after getAccount") at := &engine.ActionTiming{ AccountIds: []string{tag}, } @@ -141,6 +143,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { if attr.Overwrite { aType = engine.DEBIT_RESET } + engine.Logger.Debug("Add balance before SetActions") at.SetActions(engine.Actions{ &engine.Action{ ActionType: aType, @@ -157,10 +160,12 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { }, }, }) + engine.Logger.Debug("Add balance before at.Execute") if err := at.Execute(); err != nil { *reply = err.Error() return err } + engine.Logger.Debug("AddBalance done!") *reply = OK return nil } diff --git a/config/config.go b/config/config.go index 2cff5aaa3..ebc2eefd5 100644 --- a/config/config.go +++ b/config/config.go @@ -191,6 +191,7 @@ type CGRConfig struct { MaxCallDuration time.Duration // The maximum call duration (used by responder when querying DerivedCharging) // ToDo: export it in configuration file RaterEnabled bool // start standalone server (no balancer) RaterBalancer string // balancer address host:port + RaterCdrStats string // address where to reach the cdrstats service. Empty to disable stats gathering <""|internal|x.y.z.y:1234> BalancerEnabled bool SchedulerEnabled bool CDRSEnabled bool // Enable CDR Server service @@ -463,6 +464,9 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error { if jsnRaterCfg.Balancer != nil { self.RaterBalancer = *jsnRaterCfg.Balancer } + if jsnRaterCfg.Cdrstats != nil { + self.RaterCdrStats = *jsnRaterCfg.Cdrstats + } } if jsnBalancerCfg != nil && jsnBalancerCfg.Enabled != nil { diff --git a/config/config_defaults.go b/config/config_defaults.go index 89b0c5220..52c1bdc8d 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -85,7 +85,8 @@ const CGRATES_CFG_JSON = ` "rater": { "enabled": false, // enable Rater service: - "balancer": "", // register to Balancer as worker: <""|internal|x.y.z.y:1234> + "balancer": "", // register to balancer as worker: <""|internal|x.y.z.y:1234> + "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> }, diff --git a/config/config_json_test.go b/config/config_json_test.go index dcf718478..09c521eaf 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -118,7 +118,7 @@ func TestDfBalancerJsonCfg(t *testing.T) { } func TestDfRaterJsonCfg(t *testing.T) { - eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer("")} + eCfg := &RaterJsonCfg{Enabled: utils.BoolPointer(false), Balancer: utils.StringPointer(""), Cdrstats: utils.StringPointer("")} if cfg, err := dfCgrJsonCfg.RaterJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 49f5b4b95..c6d9fae6c 100644 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -58,6 +58,7 @@ type BalancerJsonCfg struct { type RaterJsonCfg struct { Enabled *bool Balancer *string + Cdrstats *string } // Scheduler config section diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 568a6ab7c..ae63b0520 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -65,6 +65,7 @@ //"rater": { // "enabled": false, // enable Rater service: // "balancer": "", // register to Balancer as worker: <""|internal|x.y.z.y:1234> +// "cdrstats": "", // address where to reach the cdrstats service, empty to disable stats functionality<""|internal|x.y.z.y:1234> //},