Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] do not discard errors #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (x *CtlCommand) status(rpcc *xmlrpcclient.XMLRPCClient, processes []string)
if reply, err := rpcc.GetAllProcessInfo(); err == nil {
x.showProcessInfo(&reply, processesMap)
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand Down Expand Up @@ -245,6 +246,7 @@ func (x *CtlCommand) shutdown(rpcc *xmlrpcclient.XMLRPCClient) {
fmt.Printf("Hmmm! Something gone wrong?!\n")
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand All @@ -263,6 +265,7 @@ func (x *CtlCommand) reload(rpcc *xmlrpcclient.XMLRPCClient) {
fmt.Printf("Removed Groups: %s\n", strings.Join(reply.RemovedGroup, ","))
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand Down
19 changes: 7 additions & 12 deletions xmlrpcclient/xmlrpc-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (r *XMLRPCClient) processResponse(resp *http.Response, processBody func(io.
func (r *XMLRPCClient) postInetHTTP(method string, url string, data interface{}, processBody func(io.ReadCloser, error)) {
req, err := r.createHTTPRequest(method, url, data)
if err != nil {
processBody(emptyReader, err)
return
}

Expand All @@ -122,9 +123,7 @@ func (r *XMLRPCClient) postInetHTTP(method string, url string, data interface{},

resp, err := http.DefaultClient.Do(req)
if err != nil {
if r.verbose {
fmt.Println("Fail to send request to supervisord:", err)
}
processBody(emptyReader, fmt.Errorf("Fail to send http request to supervisord: %s", err))
return
}
r.processResponse(resp, processBody)
Expand All @@ -140,35 +139,31 @@ func (r *XMLRPCClient) postUnixHTTP(method string, path string, data interface{}
conn, err = net.Dial("unix", path)
}
if err != nil {
if r.verbose {
fmt.Printf("Fail to connect unix socket path: %s\n", r.serverurl)
}
processBody(emptyReader, fmt.Errorf("Fail to connect unix socket path: %s. %s", r.serverurl, err))
return
}
defer conn.Close()

if r.timeout > 0 {
if err := conn.SetDeadline(time.Now().Add(r.timeout)); err != nil {
processBody(emptyReader, err)
return
}
}
req, err := r.createHTTPRequest(method, "/RPC2", data)

if err != nil {
processBody(emptyReader, fmt.Errorf("Fail to create http request. %s", err))
return
}
err = req.Write(conn)
if err != nil {
if r.verbose {
fmt.Printf("Fail to write to unix socket %s\n", r.serverurl)
}
processBody(emptyReader, fmt.Errorf("Fail to write to unix socket %s", r.serverurl))
return
}
resp, err := http.ReadResponse(bufio.NewReader(conn), req)
if err != nil {
if r.verbose {
fmt.Printf("Fail to read response %s\n", err)
}
processBody(emptyReader, fmt.Errorf("Fail to read response %s", err))
return
}
r.processResponse(resp, processBody)
Expand Down