mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Starting services message uniformity
This commit is contained in:
committed by
Dan Christian Bogos
parent
bee505b278
commit
e511a2e110
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package analyzers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// NewAnalyzerService initializes a AnalyzerService
|
||||
func NewAnalyzerService() (*AnalyzerService, error) {
|
||||
return &AnalyzerService{}, nil
|
||||
}
|
||||
|
||||
// AnalyzerService is the service handling analyzer
|
||||
type AnalyzerService struct {
|
||||
}
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (aS *AnalyzerService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info("Starting Analyzer service")
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown is called to shutdown the service
|
||||
func (aS *AnalyzerService) Shutdown() error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> service shutdown initialized", utils.AnalyzerS))
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> service shutdown complete", utils.AnalyzerS))
|
||||
return nil
|
||||
}
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package analyzers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
// NewAnalyzerService initializes a AnalyzerService
|
||||
func NewAnalyzerService() (*AnalyzerService, error) {
|
||||
return &AnalyzerService{}, nil
|
||||
}
|
||||
|
||||
// AnalyzerService is the service handling analyzer
|
||||
type AnalyzerService struct {
|
||||
}
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (aS *AnalyzerService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.AnalyzerS))
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown is called to shutdown the service
|
||||
func (aS *AnalyzerService) Shutdown() error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> service shutdown initialized", utils.AnalyzerS))
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> service shutdown complete", utils.AnalyzerS))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -145,7 +145,6 @@ func startSessionS(internalSMGChan, internalRaterChan, internalResourceSChan, in
|
||||
internalStatSChan, internalSupplierSChan, internalAttrSChan, internalCDRSChan, internalChargerSChan,
|
||||
internalDispatcherSChan chan rpcclient.RpcClientConnection, server *utils.Server,
|
||||
dm *engine.DataManager, exitChan chan bool) {
|
||||
utils.Logger.Info("Starting CGRateS Session service.")
|
||||
var err error
|
||||
var ralsConns, resSConns, threshSConns, statSConns, suplSConns, attrSConns, cdrsConn, chargerSConn rpcclient.RpcClientConnection
|
||||
|
||||
@@ -696,7 +695,8 @@ func startCDRS(internalCdrSChan, internalRaterChan, internalAttributeSChan, inte
|
||||
filterS := <-filterSChan
|
||||
filterSChan <- filterS
|
||||
var err error
|
||||
utils.Logger.Info("Starting CGRateS CDRS service.")
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.CDRs))
|
||||
|
||||
var ralConn, attrSConn, thresholdSConn, statsConn, chargerSConn rpcclient.RpcClientConnection
|
||||
|
||||
intChargerSChan := internalChargerSChan
|
||||
@@ -933,7 +933,6 @@ func startResourceService(internalRsChan, internalThresholdSChan,
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
utils.Logger.Info(fmt.Sprintf("Starting Resource Service"))
|
||||
go func() {
|
||||
if err := rS.ListenAndServe(exitChan); err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<ResourceS> Could not start, error: %s", err.Error()))
|
||||
@@ -988,7 +987,6 @@ func startStatService(internalStatSChan, internalThresholdSChan,
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
utils.Logger.Info(fmt.Sprintf("Starting Stat Service"))
|
||||
go func() {
|
||||
if err := sS.ListenAndServe(exitChan); err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<StatS> Error: %s listening for packets", err.Error()))
|
||||
@@ -1021,7 +1019,6 @@ func startThresholdService(internalThresholdSChan chan rpcclient.RpcClientConnec
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
utils.Logger.Info(fmt.Sprintf("Starting Threshold Service"))
|
||||
go func() {
|
||||
if err := tS.ListenAndServe(exitChan); err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<ThresholdS> Error: %s listening for packets", err.Error()))
|
||||
@@ -1250,7 +1247,6 @@ func startDispatcherService(internalDispatcherSChan, internalAttributeSChan chan
|
||||
// startAnalyzerService fires up the AnalyzerS
|
||||
func startAnalyzerService(internalAnalyzerSChan chan rpcclient.RpcClientConnection,
|
||||
server *utils.Server, exitChan chan bool) {
|
||||
utils.Logger.Info("Starting CGRateS Analyzer service.")
|
||||
var err error
|
||||
aS, err := analyzers.NewAnalyzerService()
|
||||
if err != nil {
|
||||
|
||||
@@ -46,7 +46,7 @@ type AttributeService struct {
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (alS *AttributeService) ListenAndServe(exitChan chan bool) (err error) {
|
||||
utils.Logger.Info("Starting Attribute service")
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.AttributeS))
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
return
|
||||
|
||||
@@ -48,7 +48,7 @@ type ChargerService struct {
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (cS *ChargerService) ListenAndServe(exitChan chan bool) (err error) {
|
||||
utils.Logger.Info(fmt.Sprintf("Starting %s", utils.ChargerS))
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ChargerS))
|
||||
e := <-exitChan
|
||||
exitChan <- e
|
||||
return
|
||||
|
||||
@@ -321,6 +321,7 @@ type ResourceService struct {
|
||||
|
||||
// Called to start the service
|
||||
func (rS *ResourceService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ResourceS))
|
||||
go rS.runBackup() // start backup loop
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
|
||||
@@ -63,6 +63,7 @@ type StatService struct {
|
||||
|
||||
// ListenAndServe loops keeps the service alive
|
||||
func (sS *StatService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.StatS))
|
||||
go sS.runBackup() // start backup loop
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
|
||||
@@ -151,7 +151,7 @@ type SupplierService struct {
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (spS *SupplierService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info("Starting Supplier Service")
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.SupplierS))
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
return nil
|
||||
|
||||
@@ -139,6 +139,7 @@ type ThresholdService struct {
|
||||
|
||||
// Called to start the service
|
||||
func (tS *ThresholdService) ListenAndServe(exitChan chan bool) error {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.ThresholdS))
|
||||
go tS.runBackup() // start backup loop
|
||||
e := <-exitChan
|
||||
exitChan <- e // put back for the others listening for shutdown request
|
||||
|
||||
@@ -164,6 +164,7 @@ type SessionS struct {
|
||||
|
||||
// ListenAndServe starts the service and binds it to the listen loop
|
||||
func (sS *SessionS) ListenAndServe(exitChan chan bool) (err error) {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.SessionS))
|
||||
if sS.cgrCfg.SessionSCfg().ChannelSyncInterval != 0 {
|
||||
go func() {
|
||||
for { // Schedule sync channels to run repetately
|
||||
|
||||
Reference in New Issue
Block a user