mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
handled term signals
This commit is contained in:
@@ -399,11 +399,12 @@ func main() {
|
||||
engine.SetDebitPeriod(dp)
|
||||
}
|
||||
}
|
||||
|
||||
stopHandled := false
|
||||
// Async starts here
|
||||
if cfg.RaterEnabled && cfg.RaterBalancer != DISABLED && !cfg.BalancerEnabled {
|
||||
go registerToBalancer()
|
||||
go stopRaterSingnalHandler()
|
||||
go stopRaterSignalHandler()
|
||||
stopHandled = true
|
||||
}
|
||||
responder := &engine.Responder{ExitChan: exitChan}
|
||||
apier := &apier.ApierV1{StorDb: loadDb, RatingDb: ratingDb, AccountDb: accountDb, CdrDb: cdrDb, Config: cfg}
|
||||
@@ -413,7 +414,8 @@ func main() {
|
||||
}
|
||||
if cfg.BalancerEnabled {
|
||||
engine.Logger.Info(fmt.Sprintf("Starting CGRateS Balancer on %s.", cfg.BalancerListen))
|
||||
go stopBalancerSingnalHandler()
|
||||
go stopBalancerSignalHandler()
|
||||
stopHandled = true
|
||||
responder.Bal = bal
|
||||
go listenToRPCRequests(responder, apier, cfg.BalancerListen, cfg.RPCEncoding)
|
||||
if cfg.RaterEnabled {
|
||||
@@ -421,6 +423,9 @@ func main() {
|
||||
bal.AddClient("local", new(engine.ResponderWorker))
|
||||
}
|
||||
}
|
||||
if !stopHandled {
|
||||
go generalSignalHandler()
|
||||
}
|
||||
|
||||
if cfg.SchedulerEnabled {
|
||||
engine.Logger.Info("Starting CGRateS Scheduler.")
|
||||
|
||||
@@ -20,31 +20,41 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/scheduler"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/scheduler"
|
||||
)
|
||||
|
||||
/*
|
||||
Listens for SIGTERM, SIGINT, SIGQUIT system signals and shuts down all the registered engines.
|
||||
*/
|
||||
func stopBalancerSingnalHandler() {
|
||||
func stopBalancerSignalHandler() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
|
||||
sig := <-c
|
||||
engine.Logger.Info(fmt.Sprintf("Caught signal %v, sending shutdownto engines\n", sig))
|
||||
engine.Logger.Info(fmt.Sprintf("Caught signal %v, sending shutdown to engines\n", sig))
|
||||
bal.Shutdown("Responder.Shutdown")
|
||||
exitChan <- true
|
||||
}
|
||||
|
||||
func generalSignalHandler() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
|
||||
sig := <-c
|
||||
engine.Logger.Info(fmt.Sprintf("Caught signal %v, shuting down cgr-engine\n", sig))
|
||||
exitChan <- true
|
||||
}
|
||||
|
||||
/*
|
||||
Listens for the SIGTERM, SIGINT, SIGQUIT system signals and gracefuly unregister from balancer and closes the storage before exiting.
|
||||
*/
|
||||
func stopRaterSingnalHandler() {
|
||||
func stopRaterSignalHandler() {
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
sig := <-c
|
||||
|
||||
@@ -166,7 +166,7 @@ func (cd *CallDescriptor) LoadRatingPlans() (err error) {
|
||||
}
|
||||
|
||||
// FIXME: this method is not exhaustive but will cover 99% of cases just good
|
||||
// it will not cover very long calls with very short activation periods fo rates
|
||||
// it will not cover very long calls with very short activation periods for rates
|
||||
func (cd *CallDescriptor) getRatingPlansForPrefix(key string, recursionDepth int) (err error) {
|
||||
if recursionDepth > RECURSION_MAX_DEPTH {
|
||||
err = errors.New("Max fallback recursion depth reached!" + key)
|
||||
|
||||
Reference in New Issue
Block a user