From 656f7ddb5c9457189f9c6bd5c5ab8c5c21643f2c Mon Sep 17 00:00:00 2001 From: ice5050 Date: Tue, 1 Apr 2014 16:43:20 +0700 Subject: [PATCH] Add 2 parameter(TUSD_SERVER_READ_TIMEOUT_IN_SECONDS, TUSD_SERVER_WRITE_TIMEOUT_IN_SECONDS) --- src/cmd/tusd/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cmd/tusd/main.go b/src/cmd/tusd/main.go index 61182c3..8210b14 100644 --- a/src/cmd/tusd/main.go +++ b/src/cmd/tusd/main.go @@ -83,6 +83,20 @@ func main() { WriteTimeout: 8 * time.Second, MaxHeaderBytes: 0, } + if envReadTimeout := os.Getenv("TUSD_SERVER_READ_TIMEOUT_IN_SECONDS"); envReadTimeout != "" { + parsed, err := strconv.ParseInt(envReadTimeout, 10, 64) + if err != nil { + panic("bad TUSD_SERVER_READ_TIMEOUT_IN_SECONDS: " + err.Error()) + } + s.ReadTimeout = time.Duration(parsed) * time.Second + } + if envWriteTimeout := os.Getenv("TUSD_SERVER_WRITE_TIMEOUT_IN_SECONDS"); envWriteTimeout != "" { + parsed, err := strconv.ParseInt(envWriteTimeout, 10, 64) + if err != nil { + panic("bad TUSD_SERVER_WRITE_TIMEOUT_IN_SECONDS: " + err.Error()) + } + s.WriteTimeout = time.Duration(parsed) * time.Second + } log.Printf("servering clients at http://localhost%s", addr) if err := s.ListenAndServe(); err != nil {