mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Updated shutdown channel handling
This commit is contained in:
committed by
Dan Christian Bogos
parent
49fbe92945
commit
9de6a2d172
@@ -95,14 +95,14 @@ func (aS *AnalyzerService) deleteHits(hits search.DocumentMatchCollection) (err
|
||||
}
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
func (aS *AnalyzerService) ListenAndServe(exitChan <-chan struct{}) (err error) {
|
||||
func (aS *AnalyzerService) ListenAndServe(stopChan <-chan struct{}) (err error) {
|
||||
utils.Logger.Info(fmt.Sprintf("<%s> starting <%s> subsystem", utils.CoreS, utils.AnalyzerS))
|
||||
if err = aS.clenaUp(); err != nil { // clean up the data at the system start
|
||||
return
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-exitChan:
|
||||
case <-stopChan:
|
||||
return
|
||||
case <-time.After(aS.cfg.AnalyzerSCfg().CleanupInterval):
|
||||
if err = aS.clenaUp(); err != nil {
|
||||
|
||||
@@ -57,9 +57,9 @@ func TestNewAnalyzerService(t *testing.T) {
|
||||
if err = anz.initDB(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exitChan := make(chan struct{}, 1)
|
||||
exitChan <- struct{}{}
|
||||
if err := anz.ListenAndServe(exitChan); err != nil {
|
||||
shdChan := make(chan struct{}, 1)
|
||||
shdChan <- struct{}{}
|
||||
if err := anz.ListenAndServe(shdChan); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
anz.db.Close()
|
||||
|
||||
Reference in New Issue
Block a user