Skip to content

Commit

Permalink
stop collect before monitor on worker (#850)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard authored Oct 22, 2024
1 parent 73afb4f commit 111b03f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions dnscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ func main() {
case <-sigTerm:
logger.Warning("main - exiting...")

// and stop all workers
for _, c := range mapCollectors {
c.Stop()
}

for _, l := range mapLoggers {
l.Stop()
}

// gracefully shutdown the HTTP server
if config.Global.Telemetry.Enabled {
logger.Info("main - telemetry is stopping")
Expand All @@ -228,15 +237,7 @@ func main() {
logger.Error("main - telemetry error shutting down http server - %s", err.Error())
}

}

// and stop all workers
for _, c := range mapCollectors {
c.Stop()
}

for _, l := range mapLoggers {
l.Stop()
logger.Info("main - telemetry stopped")
}

// unblock main function
Expand Down
7 changes: 4 additions & 3 deletions workers/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ func (w *GenericWorker) LoggingDone() {
}

func (w *GenericWorker) Stop() {
w.LogInfo("stopping monitor...")
w.stopMonitor <- true
<-w.doneMonitor

w.LogInfo("stopping collect...")
w.stopRun <- true
<-w.doneRun
w.LogInfo("stopping monitor...")
w.stopMonitor <- true
<-w.doneMonitor

}

func (w *GenericWorker) Monitor() {
Expand Down

0 comments on commit 111b03f

Please sign in to comment.