mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 16:48:45 +05:00
Merge fixes
This commit is contained in:
@@ -61,6 +61,7 @@ var (
|
||||
version = flag.Bool("version", false, "Prints the application version.")
|
||||
pidFile = flag.String("pid", "", "Write pid file")
|
||||
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||
memprofile = flag.String("memprofile", "", "write memory profile to file")
|
||||
scheduledShutdown = flag.String("scheduled_shutdown", "", "shutdown the engine after this duration")
|
||||
singlecpu = flag.Bool("singlecpu", false, "Run on single CPU core")
|
||||
syslogger = flag.String("logger", "", "logger <*syslog|*stdout>")
|
||||
@@ -726,7 +727,7 @@ func main() {
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
if *scheduledShutdown != "" {
|
||||
shutdownDur, err := utils.ParseDurationWithSecs(*scheduledShutdown)
|
||||
shutdownDur, err := utils.ParseDurationWithNanosecs(*scheduledShutdown)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -742,7 +743,8 @@ func main() {
|
||||
log.Fatalf("Could not parse config: <%s>", err.Error())
|
||||
return
|
||||
}
|
||||
config.SetCgrConfig(cfg) // Share the config object
|
||||
config.SetCgrConfig(cfg) // Share the config object
|
||||
cache.NewCache(cfg.CacheCfg()) // init cache
|
||||
// init syslog
|
||||
if err = initLogger(cfg); err != nil {
|
||||
log.Fatalf("Could not initialize syslog connection, err: <%s>", err.Error())
|
||||
@@ -754,16 +756,14 @@ func main() {
|
||||
}
|
||||
utils.Logger.SetLogLevel(lgLevel)
|
||||
|
||||
// Init cache
|
||||
cache.NewCache(cfg.CacheConfig)
|
||||
|
||||
var loadDb engine.LoadStorage
|
||||
var cdrDb engine.CdrStorage
|
||||
var dm *engine.DataManager
|
||||
|
||||
if cfg.RALsEnabled || cfg.CDRStatsEnabled || cfg.PubSubServerEnabled || cfg.AliasesServerEnabled || cfg.UserServerEnabled || cfg.SchedulerEnabled {
|
||||
if cfg.RALsEnabled || cfg.CDRStatsEnabled || cfg.PubSubServerEnabled ||
|
||||
cfg.AliasesServerEnabled || cfg.UserServerEnabled || cfg.SchedulerEnabled {
|
||||
dm, err = engine.ConfigureDataStorage(cfg.DataDbType, cfg.DataDbHost, cfg.DataDbPort,
|
||||
cfg.DataDbName, cfg.DataDbUser, cfg.DataDbPass, cfg.DBDataEncoding, cfg.CacheConfig, cfg.LoadHistorySize)
|
||||
cfg.DataDbName, cfg.DataDbUser, cfg.DataDbPass, cfg.DBDataEncoding, cfg.CacheCfg(), cfg.LoadHistorySize)
|
||||
if err != nil { // Cannot configure getter database, show stopper
|
||||
utils.Logger.Crit(fmt.Sprintf("Could not configure dataDb: %s exiting!", err))
|
||||
return
|
||||
@@ -777,7 +777,8 @@ func main() {
|
||||
}
|
||||
if cfg.RALsEnabled || cfg.CDRSEnabled || cfg.SchedulerEnabled { // Only connect to storDb if necessary
|
||||
storDb, err := engine.ConfigureStorStorage(cfg.StorDBType, cfg.StorDBHost, cfg.StorDBPort,
|
||||
cfg.StorDBName, cfg.StorDBUser, cfg.StorDBPass, cfg.DBDataEncoding, cfg.StorDBMaxOpenConns, cfg.StorDBMaxIdleConns, cfg.StorDBConnMaxLifetime, cfg.StorDBCDRSIndexes)
|
||||
cfg.StorDBName, cfg.StorDBUser, cfg.StorDBPass, cfg.DBDataEncoding, cfg.StorDBMaxOpenConns,
|
||||
cfg.StorDBMaxIdleConns, cfg.StorDBConnMaxLifetime, cfg.StorDBCDRSIndexes)
|
||||
if err != nil { // Cannot configure logger database, show stopper
|
||||
utils.Logger.Crit(fmt.Sprintf("Could not configure logger database: %s exiting!", err))
|
||||
return
|
||||
@@ -930,6 +931,18 @@ func main() {
|
||||
internalPubSubSChan, internalUserSChan, internalAliaseSChan, internalRsChan, internalStatSChan, internalSMGChan)
|
||||
<-exitChan
|
||||
|
||||
if *memprofile != "" {
|
||||
f, err := os.Create(*memprofile)
|
||||
if err != nil {
|
||||
log.Fatal("could not create memory profile file: ", err)
|
||||
}
|
||||
defer f.Close()
|
||||
runtime.GC() // get up-to-date statistics
|
||||
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||
log.Fatal("could not write memory profile: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
if *pidFile != "" {
|
||||
if err := os.Remove(*pidFile); err != nil {
|
||||
utils.Logger.Warning("Could not remove pid file: " + err.Error())
|
||||
|
||||
@@ -37,74 +37,74 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneC
|
||||
serviceManager *servmanager.ServiceManager, server *utils.Server,
|
||||
dm *engine.DataManager, loadDb engine.LoadStorage, cdrDb engine.CdrStorage, stopHandled *bool, exitChan chan bool) {
|
||||
var waitTasks []chan struct{}
|
||||
|
||||
cacheCfg := cfg.CacheCfg()
|
||||
//Cache load
|
||||
cacheTaskChan := make(chan struct{})
|
||||
waitTasks = append(waitTasks, cacheTaskChan)
|
||||
go func() {
|
||||
defer close(cacheTaskChan)
|
||||
var dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs, lcrPrfIDs []string
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheDestinations]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheDestinations]; !has || !cCfg.Precache {
|
||||
dstIDs = make([]string, 0) // Don't cache any
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheReverseDestinations]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheReverseDestinations]; !has || !cCfg.Precache {
|
||||
rvDstIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheRatingPlans]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheRatingPlans]; !has || !cCfg.Precache {
|
||||
rplIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheRatingProfiles]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheRatingProfiles]; !has || !cCfg.Precache {
|
||||
rpfIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheActions]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheActions]; !has || !cCfg.Precache {
|
||||
actIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheActionPlans]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheActionPlans]; !has || !cCfg.Precache {
|
||||
aplIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheAccountActionPlans]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheAccountActionPlans]; !has || !cCfg.Precache {
|
||||
aapIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheActionTriggers]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheActionTriggers]; !has || !cCfg.Precache {
|
||||
atrgIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheSharedGroups]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheSharedGroups]; !has || !cCfg.Precache {
|
||||
sgIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheLCRRules]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheLCRRules]; !has || !cCfg.Precache {
|
||||
lcrIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheDerivedChargers]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheDerivedChargers]; !has || !cCfg.Precache {
|
||||
dcIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheAliases]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheAliases]; !has || !cCfg.Precache {
|
||||
alsIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheReverseAliases]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheReverseAliases]; !has || !cCfg.Precache {
|
||||
rvAlsIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheResourceProfiles]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheResourceProfiles]; !has || !cCfg.Precache {
|
||||
rspIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheResources]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheResources]; !has || !cCfg.Precache {
|
||||
resIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheStatQueues]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheStatQueues]; !has || !cCfg.Precache {
|
||||
stqIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheStatQueueProfiles]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheStatQueueProfiles]; !has || !cCfg.Precache {
|
||||
stqpIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheThresholds]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheThresholds]; !has || !cCfg.Precache {
|
||||
thIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheThresholdProfiles]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheThresholdProfiles]; !has || !cCfg.Precache {
|
||||
thpIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheFilters]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheFilters]; !has || !cCfg.Precache {
|
||||
fltrIDs = make([]string, 0)
|
||||
}
|
||||
if cCfg, has := cfg.CacheConfig[utils.CacheLCRProfiles]; !has || !cCfg.Precache {
|
||||
if cCfg, has := cacheCfg[utils.CacheLCRProfiles]; !has || !cCfg.Precache {
|
||||
lcrPrfIDs = make([]string, 0)
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneC
|
||||
for _, chn := range waitTasks {
|
||||
<-chn
|
||||
}
|
||||
responder := &engine.Responder{ExitChan: exitChan}
|
||||
responder := &engine.Responder{ExitChan: exitChan, MaxComputedUsage: cfg.RALsMaxComputedUsage}
|
||||
responder.SetTimeToLive(cfg.ResponseCacheTTL, nil)
|
||||
apierRpcV1 := &v1.ApierV1{StorDb: loadDb, DataManager: dm, CdrDb: cdrDb,
|
||||
Config: cfg, Responder: responder, ServManager: serviceManager,
|
||||
|
||||
@@ -81,7 +81,8 @@ func main() {
|
||||
var rater, cdrstats, users rpcclient.RpcClientConnection
|
||||
var loader engine.LoadReader
|
||||
|
||||
dm, errDataDB = engine.ConfigureDataStorage(*datadb_type, *datadb_host, *datadb_port, *datadb_name, *datadb_user, *datadb_pass, *dbdata_encoding, config.CgrConfig().CacheConfig, *loadHistorySize)
|
||||
dm, errDataDB = engine.ConfigureDataStorage(*datadb_type, *datadb_host, *datadb_port, *datadb_name,
|
||||
*datadb_user, *datadb_pass, *dbdata_encoding, config.CgrConfig().CacheCfg(), *loadHistorySize)
|
||||
if *fromStorDb || *toStorDb {
|
||||
storDb, errStorDb = engine.ConfigureLoadStorage(*stor_db_type, *stor_db_host, *stor_db_port, *stor_db_name, *stor_db_user, *stor_db_pass, *dbdata_encoding,
|
||||
config.CgrConfig().StorDBMaxOpenConns, config.CgrConfig().StorDBMaxIdleConns, config.CgrConfig().StorDBConnMaxLifetime, config.CgrConfig().StorDBCDRSIndexes)
|
||||
|
||||
@@ -66,7 +66,7 @@ var (
|
||||
inStorDBUser = flag.String("stordb_user", config.CgrConfig().StorDBUser, "The storDb user to sign in as.")
|
||||
inStorDBPass = flag.String("stordb_passwd", config.CgrConfig().StorDBPass, "The storDb user's password.")
|
||||
|
||||
loadHistorySize = flag.Int("load_history_size", config.CgrConfig().LoadHistorySize, "Limit the number of records in the load history")
|
||||
loadHistorySize = flag.Int("load_history_size", config.CgrConfig().LoadHistorySize, "Limit the number of records in the load history")
|
||||
|
||||
dbDataEncoding = flag.String("dbData_encoding", config.CgrConfig().DBDataEncoding, "The encoding used to store object Data in strings")
|
||||
inDBDataEncoding = flag.String("in_dbData_encoding", "", "The encoding used to store object Data in strings")
|
||||
@@ -86,8 +86,9 @@ func main() {
|
||||
log.Print("Initializing DataDB:", *outDataDBType)
|
||||
log.Print("Initializing storDB:", *outStorDBType)
|
||||
}
|
||||
|
||||
var dmOUT *engine.DataManager
|
||||
dmOUT, _ = engine.ConfigureDataStorage(*outDataDBType, *outDataDBHost, *outDataDBPort, *outDataDBName, *outDataDBUser, *outDataDBPass, *dbDataEncoding, config.CgrConfig().CacheConfig, *loadHistorySize)
|
||||
dmOUT, _ = engine.ConfigureDataStorage(*outDataDBType, *outDataDBHost, *outDataDBPort, *outDataDBName, *outDataDBUser, *outDataDBPass, *dbDataEncoding, config.CgrConfig().CacheCfg(), *loadHistorySize)
|
||||
storDB, err := engine.ConfigureStorStorage(*outStorDBType, *outStorDBHost, *outStorDBPort, *outStorDBName, *outStorDBUser, *outStorDBPass, *dbDataEncoding,
|
||||
config.CgrConfig().StorDBMaxOpenConns, config.CgrConfig().StorDBMaxIdleConns, config.CgrConfig().StorDBConnMaxLifetime, config.CgrConfig().StorDBCDRSIndexes)
|
||||
if err != nil {
|
||||
@@ -105,7 +106,7 @@ func main() {
|
||||
log.Print("Initializing inDataDB:", *inDataDBType)
|
||||
}
|
||||
var dmIN *engine.DataManager
|
||||
dmIN, _ = engine.ConfigureDataStorage(*inDataDBType, *inDataDBHost, *inDataDBPort, *inDataDBName, *inDataDBUser, *inDataDBPass, *dbDataEncoding, config.CgrConfig().CacheConfig, *loadHistorySize)
|
||||
dmIN, _ = engine.ConfigureDataStorage(*inDataDBType, *inDataDBHost, *inDataDBPort, *inDataDBName, *inDataDBUser, *inDataDBPass, *dbDataEncoding, config.CgrConfig().CacheCfg(), *loadHistorySize)
|
||||
inDataDB, err := migrator.ConfigureV1DataStorage(*inDataDBType, *inDataDBHost, *inDataDBPort, *inDataDBName, *inDataDBUser, *inDataDBPass, *dbDataEncoding)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
@@ -52,7 +52,7 @@ func main() {
|
||||
for i := 0; i < 10000; i++ {
|
||||
cdr := &engine.CDR{OriginID: fmt.Sprintf("httpjsonrpc_%d", i),
|
||||
ToR: utils.VOICE, OriginHost: "192.168.1.1", Source: "UNKNOWN", RequestType: utils.META_PSEUDOPREPAID,
|
||||
Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
|
||||
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
|
||||
SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC), AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC),
|
||||
Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}
|
||||
cdrs = append(cdrs, cdr)
|
||||
|
||||
@@ -61,7 +61,8 @@ var (
|
||||
)
|
||||
|
||||
func durInternalRater(cd *engine.CallDescriptor) (time.Duration, error) {
|
||||
dm, err := engine.ConfigureDataStorage(*datadb_type, *datadb_host, *datadb_port, *datadb_name, *datadb_user, *datadb_pass, *dbdata_encoding, cgrConfig.CacheConfig, *loadHistorySize)
|
||||
dm, err := engine.ConfigureDataStorage(*datadb_type, *datadb_host, *datadb_port,
|
||||
*datadb_name, *datadb_user, *datadb_pass, *dbdata_encoding, cgrConfig.CacheCfg(), *loadHistorySize)
|
||||
if err != nil {
|
||||
return nilDuration, fmt.Errorf("Could not connect to data database: %s", err.Error())
|
||||
}
|
||||
@@ -156,7 +157,7 @@ func main() {
|
||||
var timeparsed time.Duration
|
||||
var err error
|
||||
tstart := time.Now().Local()
|
||||
timeparsed, err = utils.ParseDurationWithSecs(*usage)
|
||||
timeparsed, err = utils.ParseDurationWithNanosecs(*usage)
|
||||
tend := tstart.Add(timeparsed)
|
||||
cd := &engine.CallDescriptor{
|
||||
TimeStart: tstart,
|
||||
|
||||
Reference in New Issue
Block a user