From 52e34c4da075304ee9cd6eacb708ee58a38b0d50 Mon Sep 17 00:00:00 2001 From: Sergei Egorov Date: Mon, 15 Jan 2018 21:26:44 +0100 Subject: [PATCH] Add initial timeout, trim message, better logging --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 5cbabc8..98ee055 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "log" "net" "net/url" + "strings" "time" "github.com/docker/docker/api/types" @@ -40,6 +41,8 @@ func main() { for { message, err := reader.ReadString('\n') + message = strings.TrimSpace(message) + if len(message) > 0 { query, err := url.ParseQuery(message) @@ -61,7 +64,7 @@ func main() { continue } - log.Printf("%+v\n", param) + log.Printf("Adding %s\n", param) deathNote[param] = true @@ -81,6 +84,8 @@ func main() { TimeoutLoop: for { select { + case <-time.After(1 * time.Minute): + panic("Timed out waiting for the initial connection") case <-connected: log.Println("Connected") case <-disconnected: