diff --git a/proxy/proxy.go b/proxy/proxy.go index 213e5ce..c0f6592 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -111,7 +111,11 @@ func (s *ProxyServer) checkUpstreams() { backup := false for i, v := range s.upstreams { - if v.Check() && !backup { + ok, err := v.Check() + if err != nil { + log.Printf("Upstream %v didn't pass check: %v", v.Name, err) + } + if ok && !backup { candidate = int32(i) backup = true } diff --git a/rpc/rpc.go b/rpc/rpc.go index 81003fc..cfce3ce 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -143,13 +143,13 @@ func (r *RPCClient) doPost(url, method string, params interface{}) (JSONRpcResp, return rpcResp, err } -func (r *RPCClient) Check() bool { +func (r *RPCClient) Check() (bool, error) { _, err := r.GetWork() if err != nil { - return false + return false, err } r.markAlive() - return !r.Sick() + return !r.Sick(), nil } func (r *RPCClient) Sick() bool {