Handle shutdown sequentially

This commit is contained in:
Holger Obermaier
2022-01-27 17:43:00 +01:00
parent e1d0aacd1e
commit b9236dcc31
7 changed files with 37 additions and 42 deletions

View File

@@ -225,18 +225,12 @@ func (r *metricRouter) AddOutput(output chan lp.CCMetric) {
// Close finishes / stops the metric router
func (r *metricRouter) Close() {
select {
case r.done <- true:
default:
}
cclog.ComponentDebug("MetricRouter", "CLOSE")
r.done <- true
if r.config.IntervalStamp {
cclog.ComponentDebug("MetricRouter", "TIMER CLOSE")
select {
case r.timerdone <- true:
default:
}
r.timerdone <- true
}
cclog.ComponentDebug("MetricRouter", "CLOSE")
}
// New creates a new initialized metric router

View File

@@ -1,8 +1,9 @@
package multiChanTicker
import (
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
"time"
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
)
type multiChanTicker struct {
@@ -49,8 +50,8 @@ func (t *multiChanTicker) AddChannel(channel chan time.Time) {
}
func (t *multiChanTicker) Close() {
t.done <- true
cclog.ComponentDebug("MultiChanTicker", "CLOSE")
t.done <- true
}
func NewTicker(duration time.Duration) MultiChanTicker {