connection refused errors are expectede

This commit is contained in:
Naitik Shah 2013-08-20 13:15:00 -07:00
parent 8060336110
commit eb6bada57c

View File

@ -9,6 +9,7 @@ import (
"log" "log"
"net/http" "net/http"
"os" "os"
"strings"
"sync" "sync"
"time" "time"
@ -18,7 +19,7 @@ import (
type response struct { type response struct {
Sleep time.Duration Sleep time.Duration
Pid int Pid int
Error string `json:,omitempty` Error string `json:",omitempty"`
} }
func wait(wg *sync.WaitGroup, url string) { func wait(wg *sync.WaitGroup, url string) {
@ -28,12 +29,15 @@ func wait(wg *sync.WaitGroup, url string) {
if err == nil { if err == nil {
return return
} else { } else {
e2 := json.NewEncoder(os.Stderr).Encode(&response{ // we expect connection refused
Error: err.Error(), if !strings.HasSuffix(err.Error(), "connection refused") {
Pid: os.Getpid(), e2 := json.NewEncoder(os.Stderr).Encode(&response{
}) Error: err.Error(),
if e2 != nil { Pid: os.Getpid(),
log.Fatalf("Error writing error json: %s", e2) })
if e2 != nil {
log.Fatalf("Error writing error json: %s", e2)
}
} }
} }
} }