aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.main.go.swpbin0 -> 20480 bytes
-rw-r--r--main.go12
2 files changed, 8 insertions, 4 deletions
diff --git a/.main.go.swp b/.main.go.swp
new file mode 100644
index 0000000..36e0a39
--- /dev/null
+++ b/.main.go.swp
Binary files differ
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")
}
}
}