Was writing a header when I shouldn't have.

This commit is contained in:
Travis
2013-01-18 11:52:45 -08:00
parent 927eead2b1
commit ac09366b50

View File

@@ -152,25 +152,26 @@ func serveEndpoint(w http.ResponseWriter, req *http.Request, route *Route) {
golog.Infoln("Error proxying!", err)
etype := reflect.TypeOf(err)
golog.Infoln("err type:", etype)
w.WriteHeader(http.StatusInternalServerError)
// can't figure out how to compare types so comparing strings.... lame.
if strings.Contains(etype.String(), "net.OpError") { // == reflect.TypeOf(net.OpError{}) { // couldn't figure out a better way to do this
golog.Infoln("It's a network error and less than three other workers available so we're going to remove it and start new task.")
golog.Infoln("It's a network error so we're going to remove destination.")
route.Destinations = append(route.Destinations[:destIndex], route.Destinations[destIndex + 1:]...)
err := putRoute(route)
if err != nil {
golog.Infoln("couldn't update routing table:", err)
golog.Infoln("Couldn't update routing table:", err)
common.SendError(w, 500, fmt.Sprintln("couldn't update routing table", err))
return
}
golog.Infoln("New route:", route)
if len(route.Destinations) < 3 {
golog.Infoln("After network error, there are less than three destinations, so starting a new one. ")
// always want at least three running
startNewWorker(route)
}
serveEndpoint(w, req, route)
return
}
common.SendError(w, 500, fmt.Sprintln("Internal error occurred:", err))
return
}
golog.Infoln("Served!")