mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Fix errcheck errors in app
This commit is contained in:
@@ -59,7 +59,10 @@ func makeTopologyHandlers(
|
||||
|
||||
// Websocket for the full topology. This route overlaps with the next.
|
||||
get.HandleFunc(base+"/ws", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
if err := r.ParseForm(); err != nil {
|
||||
respondWith(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
loop := websocketLoop
|
||||
if t := r.Form.Get("t"); t != "" {
|
||||
var err error
|
||||
@@ -140,7 +143,9 @@ func handleWebsocket(
|
||||
diff := report.TopoDiff(previousTopo, newTopo)
|
||||
previousTopo = newTopo
|
||||
|
||||
conn.SetWriteDeadline(time.Now().Add(websocketTimeout))
|
||||
if err := conn.SetWriteDeadline(time.Now().Add(websocketTimeout)); err != nil {
|
||||
return
|
||||
}
|
||||
if err := conn.WriteJSON(diff); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
11
app/main.go
11
app/main.go
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"log/syslog"
|
||||
"net/http"
|
||||
@@ -28,7 +27,6 @@ func main() {
|
||||
probes = flag.String("probes", strings.Join(defaultProbes, ","), "list of probe endpoints, comma separated")
|
||||
batch = flag.Duration("batch", 1*time.Second, "batch interval")
|
||||
window = flag.Duration("window", 15*time.Second, "window")
|
||||
pidfile = flag.String("pidfile", "", "write PID file")
|
||||
listen = flag.String("http.address", ":"+strconv.Itoa(xfer.AppPort), "webserver listen address")
|
||||
)
|
||||
flag.Parse()
|
||||
@@ -57,15 +55,6 @@ func main() {
|
||||
log.SetOutput(f)
|
||||
}
|
||||
|
||||
if *pidfile != "" {
|
||||
err := ioutil.WriteFile(*pidfile, []byte(fmt.Sprint(os.Getpid())), 0644)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return
|
||||
}
|
||||
defer os.Remove(*pidfile)
|
||||
}
|
||||
|
||||
log.Printf("app starting, version %s", version)
|
||||
|
||||
// Collector deals with the probes, and generates merged reports.
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -9,5 +10,7 @@ func respondWith(w http.ResponseWriter, code int, response interface{}) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Add("Cache-Control", "no-cache")
|
||||
w.WriteHeader(code)
|
||||
json.NewEncoder(w).Encode(response)
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user