1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 08:00:57 +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
EnableGzip bool // enable gzip
DirectoryIndex bool //ebable DirectoryIndex default is false
EnbaleHotUpdate bool //enable HotUpdate default is false
)
func init() {
@ -93,16 +94,21 @@ func (app *App) Run() {
}
err = fcgi.Serve(l, app.Handlers)
} else {
server := &http.Server{Handler: app.Handlers}
laddr, err := net.ResolveTCPAddr("tcp", addr)
if nil != err {
BeeLogger.Fatal("ResolveTCPAddr:", err)
if EnbaleHotUpdate {
server := &http.Server{Handler: app.Handlers}
laddr, err := net.ResolveTCPAddr("tcp", addr)
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 {
BeeLogger.Fatal("ListenAndServe: ", err)

View File

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