From 404ed197207636bdf73a4bbaabb0a64f215731ad Mon Sep 17 00:00:00 2001 From: Markus Grüneis Date: Sat, 25 Oct 2014 00:26:16 +0200 Subject: hub: Add many debug printfs. --- src/hub/src/spreadspace.org/sfive/s5srvForward.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go index b5ff45a..00542a4 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go @@ -67,10 +67,13 @@ tryResync: lastId, _, err := self.getLastUpdate(baseurl, client) if err != nil { + s5l.Printf("fwd: lastupdate returned err: %v", err) time.Sleep(5 * time.Second) continue tryResync } + s5l.Printf("fwd: lastupdate: %d", lastId) + nextBatch: for { updates, err := self.store.GetUpdatesAfter(lastId) @@ -80,6 +83,8 @@ tryResync: continue nextBatch } + s5l.Printf("fwd: got %d updates", len(updates)) + if len(updates) == 0 { time.Sleep(1 * time.Second) continue nextBatch @@ -91,16 +96,25 @@ tryResync: s5l.Panicf("fwd: encode failed: %v\n", err) } - _, err = client.Post(url, "application/json", bytes.NewBuffer(data)) + s5l.Printf("fwd: marshal OK") + + resp, err := client.Post(url, "application/json", bytes.NewBuffer(data)) if err != nil { s5l.Printf("fwd: post failed: %v\n", err) continue tryResync // TODO retry etc. } + resp.Body.Close() + if resp.StatusCode != http.StatusOK { + s5l.Printf("fwd: post failed: %s\n", resp.Status) + continue tryResync + } // } + s5l.Printf("fwd: post OK") + lastId = findMaxId(updates) - s5tl.Printf("fwd: new lastid: %d", lastId) + s5l.Printf("fwd: new lastid: %d", lastId) time.Sleep(2 * time.Second) } } -- cgit v1.2.3