Updated shutdown channel handling

This commit is contained in:
Trial97
2020-11-27 15:35:27 +02:00
committed by Dan Christian Bogos
parent 49fbe92945
commit 9de6a2d172
50 changed files with 543 additions and 398 deletions

View File

@@ -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 {

View File

@@ -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()