1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 19:20:59 +00:00

add config to countol if enable hotupdate

This commit is contained in:
astaxie 2013-06-28 22:09:08 +08:00
parent d0bbc67b27
commit d627ec013e
2 changed files with 42 additions and 33 deletions

View File

@ -40,6 +40,7 @@ var (
MaxMemory int64 MaxMemory int64
EnableGzip bool // enable gzip EnableGzip bool // enable gzip
DirectoryIndex bool //ebable DirectoryIndex default is false DirectoryIndex bool //ebable DirectoryIndex default is false
EnbaleHotUpdate bool //enable HotUpdate default is false
) )
func init() { func init() {
@ -93,16 +94,21 @@ func (app *App) Run() {
} }
err = fcgi.Serve(l, app.Handlers) err = fcgi.Serve(l, app.Handlers)
} else { } else {
server := &http.Server{Handler: app.Handlers} if EnbaleHotUpdate {
laddr, err := net.ResolveTCPAddr("tcp", addr) server := &http.Server{Handler: app.Handlers}
if nil != err { laddr, err := net.ResolveTCPAddr("tcp", addr)
BeeLogger.Fatal("ResolveTCPAddr:", err) if nil != err {
BeeLogger.Fatal("ResolveTCPAddr:", err)
}
l, err = GetInitListner(laddr)
theStoppable = newStoppable(l)
err = server.Serve(theStoppable)
theStoppable.wg.Wait()
CloseSelf()
} else {
err = http.ListenAndServe(addr, app.Handlers)
} }
l, err = GetInitListner(laddr)
theStoppable = newStoppable(l)
err = server.Serve(theStoppable)
theStoppable.wg.Wait()
CloseSelf()
} }
if err != nil { if err != nil {
BeeLogger.Fatal("ListenAndServe: ", err) BeeLogger.Fatal("ListenAndServe: ", err)

View File

@ -133,49 +133,52 @@ func ParseConfig() (err error) {
if v, err := AppConfig.Int("httpport"); err == nil { if v, err := AppConfig.Int("httpport"); err == nil {
HttpPort = v HttpPort = v
} }
if v, err := AppConfig.Int64("maxmemory"); err == nil { if maxmemory, err := AppConfig.Int64("maxmemory"); err == nil {
MaxMemory = v MaxMemory = maxmemory
} }
AppName = AppConfig.String("appname") AppName = AppConfig.String("appname")
if runmode := AppConfig.String("runmode"); runmode != "" { if runmode := AppConfig.String("runmode"); runmode != "" {
RunMode = runmode RunMode = runmode
} }
if ar, err := AppConfig.Bool("autorender"); err == nil { if autorender, err := AppConfig.Bool("autorender"); err == nil {
AutoRender = ar AutoRender = autorender
} }
if ar, err := AppConfig.Bool("autorecover"); err == nil { if autorecover, err := AppConfig.Bool("autorecover"); err == nil {
RecoverPanic = ar RecoverPanic = autorecover
} }
if ar, err := AppConfig.Bool("pprofon"); err == nil { if pprofon, err := AppConfig.Bool("pprofon"); err == nil {
PprofOn = ar PprofOn = pprofon
} }
if views := AppConfig.String("viewspath"); views != "" { if views := AppConfig.String("viewspath"); views != "" {
ViewsPath = views ViewsPath = views
} }
if ar, err := AppConfig.Bool("sessionon"); err == nil { if sessionon, err := AppConfig.Bool("sessionon"); err == nil {
SessionOn = ar SessionOn = sessionon
} }
if ar := AppConfig.String("sessionprovider"); ar != "" { if sessProvider := AppConfig.String("sessionprovider"); sessProvider != "" {
SessionProvider = ar SessionProvider = sessProvider
} }
if ar := AppConfig.String("sessionname"); ar != "" { if sessName := AppConfig.String("sessionname"); sessName != "" {
SessionName = ar SessionName = sessName
} }
if ar := AppConfig.String("sessionsavepath"); ar != "" { if sesssavepath := AppConfig.String("sessionsavepath"); sesssavepath != "" {
SessionSavePath = ar SessionSavePath = sesssavepath
} }
if ar, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && ar != 0 { if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
int64val, _ := strconv.ParseInt(strconv.Itoa(ar), 10, 64) int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
SessionGCMaxLifetime = int64val SessionGCMaxLifetime = int64val
} }
if ar, err := AppConfig.Bool("usefcgi"); err == nil { if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
UseFcgi = ar UseFcgi = usefcgi
} }
if ar, err := AppConfig.Bool("enablegzip"); err == nil { if enablegzip, err := AppConfig.Bool("enablegzip"); err == nil {
EnableGzip = ar EnableGzip = enablegzip
} }
if ar, err := AppConfig.Bool("directoryindex"); err == nil { if directoryindex, err := AppConfig.Bool("directoryindex"); err == nil {
DirectoryIndex = ar DirectoryIndex = directoryindex
}
if hotupdate, err := AppConfig.Bool("hotupdate"); err == nil {
EnbaleHotUpdate = hotupdate
} }
} }
return nil return nil