From c8d750abd24e8c0fe682cb54ea2f092298f68702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz> Date: Thu, 17 Feb 2022 12:18:56 +0100 Subject: [PATCH] Debug output, fix members size --- openapi.yaml | 2 +- tools/online-counter/online.go | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/openapi.yaml b/openapi.yaml index 2962988..4ae6b28 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: - version: "3.1.0" + version: "3.1.1" title: CF Online description: CF Online license: diff --git a/tools/online-counter/online.go b/tools/online-counter/online.go index 69a5ab5..d95c1ed 100644 --- a/tools/online-counter/online.go +++ b/tools/online-counter/online.go @@ -20,6 +20,12 @@ const tarpitFactor = 1000.0 func main() { + debug := os.Getenv("DEBUG") != "" + + if debug { + fmt.Println("Starting") + } + // konfigurace redis klienta options, err := redis.ParseURL(os.Getenv("CFG_REDIS")) if err != nil { @@ -30,6 +36,10 @@ func main() { rdb := redis.NewClient(options) ctx := rdb.Context() + if debug { + fmt.Println("Connected to redis") + } + // ukonceni prace redis klienta defer func() { err := rdb.Close() @@ -61,7 +71,7 @@ func main() { if isMember { event.Members++ } - event.GroupSizeFull, event.GroupSizeHalf = member_group_size(event.All) + event.GroupSizeFull, event.GroupSizeHalf = member_group_size(event.Members) online[key[1]] = event } @@ -85,8 +95,8 @@ func main() { message := fmt.Sprintf("%v", count) message = message[1 : len(message)-1] - if os.Getenv("DEBUG") != "" { - fmt.Println(topic, message) + if debug { + fmt.Printf("Counts for event %s: %s\n", event, message) } err = rdb.Publish(ctx, topic, message).Err() -- GitLab