aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/main.go b/main.go
index 9725d98..fcd8bbf 100644
--- a/main.go
+++ b/main.go
@@ -146,10 +146,9 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna
numConnect := 0
numOnions := 0
numAll := 0
- output := func() {
- log.Printf("SUMMARY: %d/%d connected, %d sites configured Onion-Location\n", numConnect, numAll, numOnions)
+ output := func(prefix string) {
+ log.Printf("%s: %d/%d connected, %d sites configured Onion-Location\n", prefix, numConnect, numAll, numOnions)
}
-
handleAnswer := func(a qna.Answer) {
numAll += 1
if !a.OK {
@@ -163,7 +162,10 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna
}
}
- defer output()
+ metrics := time.NewTicker(opts.MetricsInterval)
+ defer metrics.Stop()
+
+ defer output("SUMMARY")
for {
select {
case <-ctx.Done():
@@ -178,6 +180,8 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna
}
case a := <-answerCh:
handleAnswer(a)
+ case <-metrics.C:
+ output("INFO")
}
}
}