From e511a2e110709bafe1dc0ba110ff0cd20272c3da Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 27 Aug 2019 03:53:28 -0400 Subject: [PATCH] Starting services message uniformity --- analyzers/analyzers.go | 98 ++++++++++++++++++------------------ cmd/cgr-engine/cgr-engine.go | 8 +-- engine/attributes.go | 2 +- engine/chargers.go | 2 +- engine/resources.go | 1 + engine/stats.go | 1 + engine/suppliers.go | 2 +- engine/thresholds.go | 1 + sessions/sessions.go | 1 + 9 files changed, 58 insertions(+), 58 deletions(-) diff --git a/analyzers/analyzers.go b/analyzers/analyzers.go index 6348ab5fa..a608f2a9a 100755 --- a/analyzers/analyzers.go +++ b/analyzers/analyzers.go @@ -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 -*/ - -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 +*/ + +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 +} diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index f4f74aa06..dffbe9f4d 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -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(" 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(" 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(" 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 { diff --git a/engine/attributes.go b/engine/attributes.go index a12a33973..f471f0b89 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -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 diff --git a/engine/chargers.go b/engine/chargers.go index d1bb89fab..a70f5a5ca 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -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 diff --git a/engine/resources.go b/engine/resources.go index 43263b89c..e9eec00c0 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -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 diff --git a/engine/stats.go b/engine/stats.go index e6180d8b3..7bbc848bf 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -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 diff --git a/engine/suppliers.go b/engine/suppliers.go index d852f0a87..e32177d89 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -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 diff --git a/engine/thresholds.go b/engine/thresholds.go index 3ef0e9f13..3ff720cde 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -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 diff --git a/sessions/sessions.go b/sessions/sessions.go index a9176154d..cb1e5dd84 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -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