mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding initial stopChan to the engine
This commit is contained in:
@@ -59,7 +59,9 @@ func runCGREngine(fs []string) (err error) {
|
||||
if cfg, err = services.InitConfigFromPath(ctx, *flags.CfgPath, *flags.NodeID, *flags.LogLevel); err != nil || *flags.CheckConfig {
|
||||
return
|
||||
}
|
||||
cgr := services.NewCGREngine(cfg, servmanager.NewServiceIndexer(), []servmanager.Service{})
|
||||
|
||||
stopChan := make(chan struct{})
|
||||
cgr := services.NewCGREngine(stopChan, cfg, servmanager.NewServiceIndexer(), []servmanager.Service{})
|
||||
defer cgr.Stop(*flags.PidFile)
|
||||
|
||||
if err = cgr.Run(ctx, cancel, flags, vers,
|
||||
@@ -73,6 +75,7 @@ func runCGREngine(fs []string) (err error) {
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
//<-stopChan
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,13 @@ import (
|
||||
"github.com/cgrates/rpcclient"
|
||||
)
|
||||
|
||||
func NewCGREngine(cfg *config.CGRConfig, sIdxr *servmanager.ServiceIndexer,
|
||||
func NewCGREngine(stopChan chan struct{}, cfg *config.CGRConfig, sIdxr *servmanager.ServiceIndexer,
|
||||
services []servmanager.Service) *CGREngine {
|
||||
cM := engine.NewConnManager(cfg)
|
||||
caps := engine.NewCaps(cfg.CoreSCfg().Caps, cfg.CoreSCfg().CapsStrategy)
|
||||
shdWg := new(sync.WaitGroup)
|
||||
return &CGREngine{
|
||||
stopChan: stopChan,
|
||||
cfg: cfg, // Engine configuration
|
||||
cM: cM,
|
||||
caps: caps, // caps is used to limit RPC CPS
|
||||
@@ -93,6 +94,8 @@ func NewCGREngine(cfg *config.CGRConfig, sIdxr *servmanager.ServiceIndexer,
|
||||
}
|
||||
|
||||
type CGREngine struct {
|
||||
stopChan chan struct{}
|
||||
|
||||
cfg *config.CGRConfig
|
||||
|
||||
srvManager *servmanager.ServiceManager
|
||||
@@ -404,7 +407,7 @@ func (cgr *CGREngine) startServices(ctx *context.Context, shtDw context.CancelFu
|
||||
}
|
||||
|
||||
// Run will run the CGREngine, calling it's init and startServices
|
||||
func (cgr *CGREngine) Run(ctx *context.Context, shtDw context.CancelFunc,
|
||||
func (cgr *CGREngine) Run(ctx *context.Context, shtDw context.CancelFunc, stopChan chan struct{},
|
||||
flags *CGREngineFlags, vers string, memProfParams cores.MemoryProfilingParams) (err error) {
|
||||
if err = cgr.init(ctx, shtDw, flags, vers); err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user