added cache_dump_dir conf and moved stuf from log

This commit is contained in:
Radu Ioan Fericean
2016-06-14 19:42:56 +03:00
parent 7aca6d2a73
commit a68df14ce7
7 changed files with 41 additions and 31 deletions

View File

@@ -18,9 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package config
import (
"github.com/cgrates/cgrates/utils"
"reflect"
"testing"
"github.com/cgrates/cgrates/utils"
)
func TestCdreCfgClone(t *testing.T) {
@@ -46,7 +47,7 @@ func TestCdreCfgClone(t *testing.T) {
CostShiftDigits: 0,
MaskDestinationID: "MASKED_DESTINATIONS",
MaskLength: 0,
ExportFolder: "/var/log/cgrates/cdre",
ExportFolder: "/var/spool/cgrates/cdre",
ContentFields: initContentFlds,
}
eClnContentFlds := []*CfgCdrField{
@@ -68,7 +69,7 @@ func TestCdreCfgClone(t *testing.T) {
CostShiftDigits: 0,
MaskDestinationID: "MASKED_DESTINATIONS",
MaskLength: 0,
ExportFolder: "/var/log/cgrates/cdre",
ExportFolder: "/var/spool/cgrates/cdre",
HeaderFields: emptyFields,
ContentFields: eClnContentFlds,
TrailerFields: emptyFields,

View File

@@ -85,7 +85,7 @@ func NewDefaultCGRConfig() (*CGRConfig, error) {
return nil, err
}
cfg.dfltCdreProfile = cfg.CdreProfiles[utils.META_DEFAULT].Clone() // So default will stay unique, will have nil pointer in case of no defaults loaded which is an extra check
cfg.dfltCdrcProfile = cfg.CdrcProfiles["/var/log/cgrates/cdrc/in"][0].Clone()
cfg.dfltCdrcProfile = cfg.CdrcProfiles["/var/spool/cgrates/cdrc/in"][0].Clone()
dfltFsConnConfig = cfg.SmFsConfig.EventSocketConns[0] // We leave it crashing here on purpose if no Connection defaults defined
dfltKamConnConfig = cfg.SmKamConfig.EvapiConns[0]
if err := cfg.checkConfigSanity(); err != nil {
@@ -212,6 +212,7 @@ type CGRConfig struct {
HttpFailedDir string // Directory path where we store failed http requests
MaxCallDuration time.Duration // The maximum call duration (used by responder when querying DerivedCharging) // ToDo: export it in configuration file
LockingTimeout time.Duration // locking mechanism timeout to avoid deadlocks
CacheDumpDir string // cache dump for faster start (leave empty to disable)b
RALsEnabled bool // start standalone server (no balancer)
RALsBalancer string // balancer address host:port
RALsCDRStatSConns []*HaPoolConfig // address where to reach the cdrstats service. Empty to disable stats gathering <""|internal|x.y.z.y:1234>
@@ -699,6 +700,9 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
return err
}
}
if jsnGeneralCfg.Cache_dump_dir != nil {
self.CacheDumpDir = *jsnGeneralCfg.Cache_dump_dir
}
}
if jsnListenCfg != nil {

View File

@@ -31,9 +31,9 @@ const CGRATES_CFG_JSON = `
"http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate
"rounding_decimals": 5, // system level precision for floats
"dbdata_encoding": "msgpack", // encoding used to store object data in strings: <msgpack|json>
"tpexport_dir": "/var/log/cgrates/tpe", // path towards export folder for offline Tariff Plans
"tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans
"httpposter_attempts": 3, // number of http attempts before considering request failed (eg: *call_url)
"http_failed_dir": "/var/log/cgrates/http_failed", // directory path where we store failed http requests
"http_failed_dir": "/var/spool/cgrates/http_failed", // directory path where we store failed http requests
"default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated>
"default_category": "call", // default category to consider when missing from requests
"default_tenant": "cgrates.org", // default tenant to consider when missing from requests
@@ -45,6 +45,8 @@ const CGRATES_CFG_JSON = `
"response_cache_ttl": "0s", // the life span of a cached response
"internal_ttl": "2m", // maximum duration to wait for internal connections before giving up
"locking_timeout": "5s", // timeout internal locks to avoid deadlocks
"cache_dump_dir": "/var/lib/cgrates/cache_dump", // cache dump for faster start (leave empty to disable)b
},
@@ -146,7 +148,7 @@ const CGRATES_CFG_JSON = `
"cost_shift_digits": 0, // shift digits in the cost on export (eg: convert from EUR to cents)
"mask_destination_id": "MASKED_DESTINATIONS", // destination id containing called addresses to be masked on export
"mask_length": 0, // length of the destination suffix to be masked
"export_folder": "/var/log/cgrates/cdre", // path where the exported CDRs will be placed
"export_folder": "/var/spool/cgrates/cdre", // path where the exported CDRs will be placed
"header_fields": [], // template of the exported header fields
"content_fields": [ // template of the exported content fields
{"tag": "CGRID", "field_id": "CGRID", "type": "*composed", "value": "CGRID"},
@@ -177,15 +179,15 @@ const CGRATES_CFG_JSON = `
"dry_run": false, // do not send the CDRs to CDRS, just parse them
"cdrs_conns": [
{"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234>
],
],
"cdr_format": "csv", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore>
"field_separator": ",", // separator used in case of csv files
"timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
"run_delay": 0, // sleep interval in seconds between consecutive runs, 0 to use automation via inotify
"max_open_files": 1024, // maximum simultaneous files to process, 0 for unlimited
"data_usage_multiply_factor": 1024, // conversion factor for data usage
"cdr_in_dir": "/var/log/cgrates/cdrc/in", // absolute path towards the directory where the CDRs are stored
"cdr_out_dir": "/var/log/cgrates/cdrc/out", // absolute path towards the directory where processed CDRs will be moved
"cdr_in_dir": "/var/spool/cgrates/cdrc/in", // absolute path towards the directory where the CDRs are stored
"cdr_out_dir": "/var/spool/cgrates/cdrc/out", // absolute path towards the directory where processed CDRs will be moved
"failed_calls_prefix": "missed_calls", // used in case of flatstore CDRs to avoid searching for BYE records
"cdr_path": "", // path towards one CDR element in case of XML CDRs
"cdr_source_id": "freeswitch_csv", // free form field, tag identifying the source of the CDRs within CDRS database
@@ -298,7 +300,7 @@ const CGRATES_CFG_JSON = `
"dictionaries_dir": "/usr/share/cgrates/diameter/dict/", // path towards directory holding additional dictionaries to load
"sm_generic_conns": [
{"address": "*internal"} // connection towards SMG component for session management
],
],
"pubsubs_conns": [], // address where to reach the pubusb service, empty to disable pubsub functionality: <""|*internal|x.y.z.y:1234>
"create_cdr": true, // create CDR out of CCR terminate and send it to SMG component
"debit_interval": "5m", // interval for CCR updates
@@ -342,7 +344,7 @@ const CGRATES_CFG_JSON = `
"historys": {
"enabled": false, // starts History service: <true|false>.
"history_dir": "/var/log/cgrates/history", // location on disk where to store history files.
"history_dir": "/var/lib/cgrates/history", // location on disk where to store history files.
"save_interval": "1s", // interval to save changed cache into .git archive
},

View File

@@ -42,9 +42,9 @@ func TestDfGeneralJsonCfg(t *testing.T) {
Http_skip_tls_verify: utils.BoolPointer(false),
Rounding_decimals: utils.IntPointer(5),
Dbdata_encoding: utils.StringPointer("msgpack"),
Tpexport_dir: utils.StringPointer("/var/log/cgrates/tpe"),
Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"),
Httpposter_attempts: utils.IntPointer(3),
Http_failed_dir: utils.StringPointer("/var/log/cgrates/http_failed"),
Http_failed_dir: utils.StringPointer("/var/spool/cgrates/http_failed"),
Default_request_type: utils.StringPointer(utils.META_RATED),
Default_category: utils.StringPointer("call"),
Default_tenant: utils.StringPointer("cgrates.org"),
@@ -55,7 +55,8 @@ func TestDfGeneralJsonCfg(t *testing.T) {
Reply_timeout: utils.StringPointer("2s"),
Response_cache_ttl: utils.StringPointer("0s"),
Internal_ttl: utils.StringPointer("2m"),
Locking_timeout: utils.StringPointer("5s")}
Locking_timeout: utils.StringPointer("5s"),
Cache_dump_dir: utils.StringPointer("/var/lib/cgrates/cache_dump")}
if gCfg, err := dfCgrJsonCfg.GeneralJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, gCfg) {
@@ -263,7 +264,7 @@ func TestDfCdreJsonCfgs(t *testing.T) {
Cost_shift_digits: utils.IntPointer(0),
Mask_destination_id: utils.StringPointer("MASKED_DESTINATIONS"),
Mask_length: utils.IntPointer(0),
Export_folder: utils.StringPointer("/var/log/cgrates/cdre"),
Export_folder: utils.StringPointer("/var/spool/cgrates/cdre"),
Header_fields: &eFields,
Content_fields: &eContentFlds,
Trailer_fields: &eFields,
@@ -320,8 +321,8 @@ func TestDfCdrcJsonCfg(t *testing.T) {
Run_delay: utils.IntPointer(0),
Max_open_files: utils.IntPointer(1024),
Data_usage_multiply_factor: utils.Float64Pointer(1024.0),
Cdr_in_dir: utils.StringPointer("/var/log/cgrates/cdrc/in"),
Cdr_out_dir: utils.StringPointer("/var/log/cgrates/cdrc/out"),
Cdr_in_dir: utils.StringPointer("/var/spool/cgrates/cdrc/in"),
Cdr_out_dir: utils.StringPointer("/var/spool/cgrates/cdrc/out"),
Failed_calls_prefix: utils.StringPointer("missed_calls"),
Cdr_path: utils.StringPointer(""),
Cdr_source_id: utils.StringPointer("freeswitch_csv"),
@@ -529,7 +530,7 @@ func TestDiameterAgentJsonCfg(t *testing.T) {
func TestDfHistServJsonCfg(t *testing.T) {
eCfg := &HistServJsonCfg{
Enabled: utils.BoolPointer(false),
History_dir: utils.StringPointer("/var/log/cgrates/history"),
History_dir: utils.StringPointer("/var/lib/cgrates/history"),
Save_interval: utils.StringPointer("1s"),
}
if cfg, err := dfCgrJsonCfg.HistServJsonCfg(); err != nil {

View File

@@ -34,7 +34,7 @@ func TestLoadCdrcConfigMultipleFiles(t *testing.T) {
eCgrCfg, _ := NewDefaultCGRConfig()
eCgrCfg.CdrcProfiles = make(map[string][]*CdrcConfig)
// Default instance first
eCgrCfg.CdrcProfiles["/var/log/cgrates/cdrc/in"] = []*CdrcConfig{
eCgrCfg.CdrcProfiles["/var/spool/cgrates/cdrc/in"] = []*CdrcConfig{
&CdrcConfig{
ID: utils.META_DEFAULT,
Enabled: false,
@@ -44,8 +44,8 @@ func TestLoadCdrcConfigMultipleFiles(t *testing.T) {
DataUsageMultiplyFactor: 1024,
RunDelay: 0,
MaxOpenFiles: 1024,
CdrInDir: "/var/log/cgrates/cdrc/in",
CdrOutDir: "/var/log/cgrates/cdrc/out",
CdrInDir: "/var/spool/cgrates/cdrc/in",
CdrOutDir: "/var/spool/cgrates/cdrc/out",
FailedCallsPrefix: "missed_calls",
CDRPath: utils.HierarchyPath([]string{""}),
CdrSourceId: "freeswitch_csv",

View File

@@ -37,6 +37,7 @@ type GeneralJsonCfg struct {
Response_cache_ttl *string
Internal_ttl *string
Locking_timeout *string
Cache_dump_dir *string
}
// Listen config section

View File

@@ -10,9 +10,9 @@
// "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate
// "rounding_decimals": 5, // system level precision for floats
// "dbdata_encoding": "msgpack", // encoding used to store object data in strings: <msgpack|json>
// "tpexport_dir": "/var/log/cgrates/tpe", // path towards export folder for offline Tariff Plans
// "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans
// "httpposter_attempts": 3, // number of http attempts before considering request failed (eg: *call_url)
// "http_failed_dir": "/var/log/cgrates/http_failed", // directory path where we store failed http requests
// "http_failed_dir": "/var/spool/cgrates/http_failed", // directory path where we store failed http requests
// "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated>
// "default_category": "call", // default category to consider when missing from requests
// "default_tenant": "cgrates.org", // default tenant to consider when missing from requests
@@ -24,6 +24,7 @@
// "response_cache_ttl": "0s", // the life span of a cached response
// "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up
// "locking_timeout": "5s", // timeout internal locks to avoid deadlocks
// "cache_dump_dir": "/var/lib/cgrates/cache_dump" // cache dump for faster start (leave empty to disable)
// },
@@ -125,7 +126,7 @@
// "cost_shift_digits": 0, // shift digits in the cost on export (eg: convert from EUR to cents)
// "mask_destination_id": "MASKED_DESTINATIONS", // destination id containing called addresses to be masked on export
// "mask_length": 0, // length of the destination suffix to be masked
// "export_folder": "/var/log/cgrates/cdre", // path where the exported CDRs will be placed
// "export_folder": "/var/spool/cgrates/cdre", // path where the exported CDRs will be placed
// "header_fields": [], // template of the exported header fields
// "content_fields": [ // template of the exported content fields
// {"tag": "CGRID", "field_id": "CGRID", "type": "*composed", "value": "CGRID"},
@@ -156,15 +157,15 @@
// "dry_run": false, // do not send the CDRs to CDRS, just parse them
// "cdrs_conns": [
// {"address": "*internal"} // address where to reach CDR server. <*internal|x.y.z.y:1234>
// ],
// ],
// "cdr_format": "csv", // CDR file format <csv|freeswitch_csv|fwv|opensips_flatstore>
// "field_separator": ",", // separator used in case of csv files
// "timezone": "", // timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>
// "run_delay": 0, // sleep interval in seconds between consecutive runs, 0 to use automation via inotify
// "max_open_files": 1024, // maximum simultaneous files to process, 0 for unlimited
// "data_usage_multiply_factor": 1024, // conversion factor for data usage
// "cdr_in_dir": "/var/log/cgrates/cdrc/in", // absolute path towards the directory where the CDRs are stored
// "cdr_out_dir": "/var/log/cgrates/cdrc/out", // absolute path towards the directory where processed CDRs will be moved
// "cdr_in_dir": "/var/spool/cgrates/cdrc/in", // absolute path towards the directory where the CDRs are stored
// "cdr_out_dir": "/var/spool/cgrates/cdrc/out", // absolute path towards the directory where processed CDRs will be moved
// "failed_calls_prefix": "missed_calls", // used in case of flatstore CDRs to avoid searching for BYE records
// "cdr_path": "", // path towards one CDR element in case of XML CDRs
// "cdr_source_id": "freeswitch_csv", // free form field, tag identifying the source of the CDRs within CDRS database
@@ -278,7 +279,7 @@
// "dictionaries_dir": "/usr/share/cgrates/diameter/dict/", // path towards directory holding additional dictionaries to load
// "sm_generic_conns": [
// {"address": "*internal"} // connection towards SMG component for session management
// ],
// ],
// "pubsubs_conns": [], // address where to reach the pubusb service, empty to disable pubsub functionality: <""|*internal|x.y.z.y:1234>
// "create_cdr": true, // create CDR out of CCR terminate and send it to SMG component
// "debit_interval": "5m", // interval for CCR updates
@@ -322,7 +323,7 @@
// "historys": {
// "enabled": false, // starts History service: <true|false>.
// "history_dir": "/var/log/cgrates/history", // location on disk where to store history files.
// "history_dir": "/var/lib/cgrates/history", // location on disk where to store history files.
// "save_interval": "1s", // interval to save changed cache into .git archive
// },
@@ -380,4 +381,4 @@
// "tax_exemption_code_list": "", // template extracting tax exemption code list out of StoredCdr; <$RSRFields>
// },
}
}