mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
restructuring and optimizations
- moved misc and pkg to data/scripts - started recover procedure - optimized clean stale ids
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
|
||||
"github.com/cgrates/cgrates/cache2go"
|
||||
@@ -792,9 +793,11 @@ func (self *ApierV1) ReloadCache(attrs utils.ApiReloadCache, reply *string) erro
|
||||
dcsKeys[idx] = engine.DERIVEDCHARGERS_PREFIX + dc
|
||||
}
|
||||
}
|
||||
log.Print("Cache Rating")
|
||||
if err := self.RatingDb.CacheRating(dstKeys, rpKeys, rpfKeys, rpAlsKeys, lcrKeys); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Print("Cache Accounting")
|
||||
if err := self.AccountDb.CacheAccounting(actKeys, shgKeys, accAlsKeys, dcsKeys); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
//"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -302,7 +304,22 @@ func writePid() {
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
func start() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
engine.Logger.Crit(fmt.Sprintf("CRITICAL ERROR: %v", r))
|
||||
var stack [8192]byte
|
||||
runtime.Stack(stack[:], false)
|
||||
if tmpFile, err := ioutil.TempFile(os.TempDir(), "cgr_coredump"); err != nil {
|
||||
engine.Logger.Crit(fmt.Sprintf("Cannot create coredump file: %v", err))
|
||||
engine.Logger.Crit(string(stack[:]))
|
||||
} else {
|
||||
tmpFile.Write(stack[:])
|
||||
tmpFile.Close()
|
||||
engine.Logger.Crit(fmt.Sprintf("Core dumped: %s", tmpFile.Name()))
|
||||
}
|
||||
}
|
||||
}()
|
||||
flag.Parse()
|
||||
if *version {
|
||||
fmt.Println("CGRateS " + utils.VERSION)
|
||||
@@ -512,3 +529,12 @@ func main() {
|
||||
}
|
||||
engine.Logger.Info("Stopped all components. CGRateS shutdown!")
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
fmt.Fprintf(os.Stderr, "PANIC: %v\n", e)
|
||||
}
|
||||
}()
|
||||
start()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Rating system designed to be used in VoIP Carriers World
|
||||
Copyright (C) 2013 ITsysCOM
|
||||
Copyright (C) 2014 ITsysCOM
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -91,14 +91,15 @@ func CleanStalePrefixes(destIds []string) {
|
||||
}
|
||||
for prefix, idIDs := range prefixMap {
|
||||
dIDs := idIDs.Value().([]interface{})
|
||||
strdIDs := utils.ConvertInterfaceSliceToStringMap(dIDs)
|
||||
changed := false
|
||||
for _, searchedDID := range destIds {
|
||||
if i, found := utils.GetSliceMemberIndex(utils.ConvertInterfaceSliceToStringSlice(dIDs), searchedDID); found {
|
||||
if i, found := strdIDs[searchedDID]; found {
|
||||
if len(dIDs) == 1 {
|
||||
// remove de prefix from cache
|
||||
cache2go.RemKey(DESTINATION_PREFIX + prefix)
|
||||
} else {
|
||||
// delte the testination from list and put the new list in chache
|
||||
// delete the destination from list and put the new list in chache
|
||||
dIDs[i], dIDs = dIDs[len(dIDs)-1], dIDs[:len(dIDs)-1]
|
||||
changed = true
|
||||
}
|
||||
|
||||
@@ -52,9 +52,10 @@ func SliceMemberHasPrefix(ss []string, prfx string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func ConvertInterfaceSliceToStringSlice(is []interface{}) (result []string) {
|
||||
for _, i := range is {
|
||||
result = append(result, i.(string))
|
||||
func ConvertInterfaceSliceToStringMap(is []interface{}) (result map[string]int) {
|
||||
result = make(map[string]int)
|
||||
for index, i := range is {
|
||||
result[i.(string)] = index
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user