Merge pull request #26 from canton7/feature/better-logging

Add more logging in the case of relaypoolsrv internal server error
This commit is contained in:
Audrius Butkevicius 2015-12-07 11:18:34 +00:00
commit c7d51a26f6

View File

@ -28,17 +28,13 @@ func poolHandler(pool string, uri *url.URL) {
if err != nil { if err != nil {
log.Println("Error joining pool", pool, err) log.Println("Error joining pool", pool, err)
} else if resp.StatusCode == 500 { } else if resp.StatusCode == 500 {
if debug { bs, err := ioutil.ReadAll(resp.Body)
bs, err := ioutil.ReadAll(resp.Body) if err != nil {
if err != nil { log.Println("Failed to join", pool, "due to an internal server error. Could not read response:", err)
log.Println("Failed to read response body for", pool, err)
} else {
log.Println("Response for", pool, string(bs))
}
resp.Body.Close()
} else { } else {
log.Println(pool, "failed to join due to an internal server error") log.Println("Failed to join", pool, "due to an internal server error:", string(bs))
} }
resp.Body.Close()
} else if resp.StatusCode == 429 { } else if resp.StatusCode == 429 {
log.Println(pool, "under load, will retry in a minute") log.Println(pool, "under load, will retry in a minute")
time.Sleep(time.Minute) time.Sleep(time.Minute)