mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:11:29 +00:00
add HttpServerTimeOut setting
This commit is contained in:
parent
189df1280c
commit
bf9de3bcf6
11
beego.go
11
beego.go
@ -10,6 +10,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
const VERSION = "0.7.0"
|
||||
@ -41,6 +42,7 @@ var (
|
||||
EnableGzip bool // enable gzip
|
||||
DirectoryIndex bool //ebable DirectoryIndex default is false
|
||||
EnbaleHotUpdate bool //enable HotUpdate default is false
|
||||
HttpServerTimeOut int64
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -67,6 +69,7 @@ func init() {
|
||||
EnableGzip = false
|
||||
StaticDir["/static"] = "static"
|
||||
AppConfigPath = path.Join(AppPath, "conf", "app.conf")
|
||||
HttpServerTimeOut = 0
|
||||
ParseConfig()
|
||||
}
|
||||
|
||||
@ -106,7 +109,13 @@ func (app *App) Run() {
|
||||
theStoppable.wg.Wait()
|
||||
CloseSelf()
|
||||
} else {
|
||||
err = http.ListenAndServe(addr, app.Handlers)
|
||||
s := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: app.Handlers,
|
||||
ReadTimeout: time.Duration(HttpServerTimeOut) * time.Second,
|
||||
WriteTimeout: time.Duration(HttpServerTimeOut) * time.Second,
|
||||
}
|
||||
err = s.ListenAndServe()
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user