add 30 seconds http read timeout

This commit is contained in:
Chris Lu 2012-09-28 09:13:17 -07:00
parent 819de58197
commit d2dd7d1694
2 changed files with 14 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import (
"pkg/topology" "pkg/topology"
"strconv" "strconv"
"strings" "strings"
"time"
) )
func init() { func init() {
@ -140,7 +141,12 @@ func runMaster(cmd *Command, args []string) bool {
topo.StartRefreshWritableVolumes() topo.StartRefreshWritableVolumes()
log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport)) log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
e := http.ListenAndServe(":"+strconv.Itoa(*mport), nil) srv := &http.Server{
Addr:":"+strconv.Itoa(*mport),
Handler: http.DefaultServeMux,
ReadTimeout: 30*time.Second,
}
e := srv.ListenAndServe()
if e != nil { if e != nil {
log.Fatalf("Fail to start:%s", e.Error()) log.Fatalf("Fail to start:%s", e.Error())
} }

View file

@ -273,7 +273,12 @@ func runVolume(cmd *Command, args []string) bool {
log.Println("store joined at", *masterNode) log.Println("store joined at", *masterNode)
log.Println("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport)) log.Println("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport))
e := http.ListenAndServe(":"+strconv.Itoa(*vport), nil) srv := &http.Server{
Addr:":"+strconv.Itoa(*vport),
Handler: http.DefaultServeMux,
ReadTimeout: 30*time.Second,
}
e := srv.ListenAndServe()
if e != nil { if e != nil {
log.Fatalf("Fail to start:%s", e.Error()) log.Fatalf("Fail to start:%s", e.Error())
} }