add config to countol if enable hotupdate
Showing
2 changed files
with
42 additions
and
33 deletions
| ... | @@ -40,6 +40,7 @@ var ( | ... | @@ -40,6 +40,7 @@ var ( |
| 40 | MaxMemory int64 | 40 | MaxMemory int64 |
| 41 | EnableGzip bool // enable gzip | 41 | EnableGzip bool // enable gzip |
| 42 | DirectoryIndex bool //ebable DirectoryIndex default is false | 42 | DirectoryIndex bool //ebable DirectoryIndex default is false |
| 43 | EnbaleHotUpdate bool //enable HotUpdate default is false | ||
| 43 | ) | 44 | ) |
| 44 | 45 | ||
| 45 | func init() { | 46 | func init() { |
| ... | @@ -93,16 +94,21 @@ func (app *App) Run() { | ... | @@ -93,16 +94,21 @@ func (app *App) Run() { |
| 93 | } | 94 | } |
| 94 | err = fcgi.Serve(l, app.Handlers) | 95 | err = fcgi.Serve(l, app.Handlers) |
| 95 | } else { | 96 | } else { |
| 96 | server := &http.Server{Handler: app.Handlers} | 97 | if EnbaleHotUpdate { |
| 97 | laddr, err := net.ResolveTCPAddr("tcp", addr) | 98 | server := &http.Server{Handler: app.Handlers} |
| 98 | if nil != err { | 99 | laddr, err := net.ResolveTCPAddr("tcp", addr) |
| 99 | BeeLogger.Fatal("ResolveTCPAddr:", err) | 100 | if nil != err { |
| 101 | BeeLogger.Fatal("ResolveTCPAddr:", err) | ||
| 102 | } | ||
| 103 | l, err = GetInitListner(laddr) | ||
| 104 | theStoppable = newStoppable(l) | ||
| 105 | err = server.Serve(theStoppable) | ||
| 106 | theStoppable.wg.Wait() | ||
| 107 | CloseSelf() | ||
| 108 | } else { | ||
| 109 | err = http.ListenAndServe(addr, app.Handlers) | ||
| 100 | } | 110 | } |
| 101 | l, err = GetInitListner(laddr) | 111 | |
| 102 | theStoppable = newStoppable(l) | ||
| 103 | err = server.Serve(theStoppable) | ||
| 104 | theStoppable.wg.Wait() | ||
| 105 | CloseSelf() | ||
| 106 | } | 112 | } |
| 107 | if err != nil { | 113 | if err != nil { |
| 108 | BeeLogger.Fatal("ListenAndServe: ", err) | 114 | BeeLogger.Fatal("ListenAndServe: ", err) | ... | ... |
| ... | @@ -133,49 +133,52 @@ func ParseConfig() (err error) { | ... | @@ -133,49 +133,52 @@ func ParseConfig() (err error) { |
| 133 | if v, err := AppConfig.Int("httpport"); err == nil { | 133 | if v, err := AppConfig.Int("httpport"); err == nil { |
| 134 | HttpPort = v | 134 | HttpPort = v |
| 135 | } | 135 | } |
| 136 | if v, err := AppConfig.Int64("maxmemory"); err == nil { | 136 | if maxmemory, err := AppConfig.Int64("maxmemory"); err == nil { |
| 137 | MaxMemory = v | 137 | MaxMemory = maxmemory |
| 138 | } | 138 | } |
| 139 | AppName = AppConfig.String("appname") | 139 | AppName = AppConfig.String("appname") |
| 140 | if runmode := AppConfig.String("runmode"); runmode != "" { | 140 | if runmode := AppConfig.String("runmode"); runmode != "" { |
| 141 | RunMode = runmode | 141 | RunMode = runmode |
| 142 | } | 142 | } |
| 143 | if ar, err := AppConfig.Bool("autorender"); err == nil { | 143 | if autorender, err := AppConfig.Bool("autorender"); err == nil { |
| 144 | AutoRender = ar | 144 | AutoRender = autorender |
| 145 | } | 145 | } |
| 146 | if ar, err := AppConfig.Bool("autorecover"); err == nil { | 146 | if autorecover, err := AppConfig.Bool("autorecover"); err == nil { |
| 147 | RecoverPanic = ar | 147 | RecoverPanic = autorecover |
| 148 | } | 148 | } |
| 149 | if ar, err := AppConfig.Bool("pprofon"); err == nil { | 149 | if pprofon, err := AppConfig.Bool("pprofon"); err == nil { |
| 150 | PprofOn = ar | 150 | PprofOn = pprofon |
| 151 | } | 151 | } |
| 152 | if views := AppConfig.String("viewspath"); views != "" { | 152 | if views := AppConfig.String("viewspath"); views != "" { |
| 153 | ViewsPath = views | 153 | ViewsPath = views |
| 154 | } | 154 | } |
| 155 | if ar, err := AppConfig.Bool("sessionon"); err == nil { | 155 | if sessionon, err := AppConfig.Bool("sessionon"); err == nil { |
| 156 | SessionOn = ar | 156 | SessionOn = sessionon |
| 157 | } | 157 | } |
| 158 | if ar := AppConfig.String("sessionprovider"); ar != "" { | 158 | if sessProvider := AppConfig.String("sessionprovider"); sessProvider != "" { |
| 159 | SessionProvider = ar | 159 | SessionProvider = sessProvider |
| 160 | } | 160 | } |
| 161 | if ar := AppConfig.String("sessionname"); ar != "" { | 161 | if sessName := AppConfig.String("sessionname"); sessName != "" { |
| 162 | SessionName = ar | 162 | SessionName = sessName |
| 163 | } | 163 | } |
| 164 | if ar := AppConfig.String("sessionsavepath"); ar != "" { | 164 | if sesssavepath := AppConfig.String("sessionsavepath"); sesssavepath != "" { |
| 165 | SessionSavePath = ar | 165 | SessionSavePath = sesssavepath |
| 166 | } | 166 | } |
| 167 | if ar, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && ar != 0 { | 167 | if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 { |
| 168 | int64val, _ := strconv.ParseInt(strconv.Itoa(ar), 10, 64) | 168 | int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) |
| 169 | SessionGCMaxLifetime = int64val | 169 | SessionGCMaxLifetime = int64val |
| 170 | } | 170 | } |
| 171 | if ar, err := AppConfig.Bool("usefcgi"); err == nil { | 171 | if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil { |
| 172 | UseFcgi = ar | 172 | UseFcgi = usefcgi |
| 173 | } | 173 | } |
| 174 | if ar, err := AppConfig.Bool("enablegzip"); err == nil { | 174 | if enablegzip, err := AppConfig.Bool("enablegzip"); err == nil { |
| 175 | EnableGzip = ar | 175 | EnableGzip = enablegzip |
| 176 | } | 176 | } |
| 177 | if ar, err := AppConfig.Bool("directoryindex"); err == nil { | 177 | if directoryindex, err := AppConfig.Bool("directoryindex"); err == nil { |
| 178 | DirectoryIndex = ar | 178 | DirectoryIndex = directoryindex |
| 179 | } | ||
| 180 | if hotupdate, err := AppConfig.Bool("hotupdate"); err == nil { | ||
| 181 | EnbaleHotUpdate = hotupdate | ||
| 179 | } | 182 | } |
| 180 | } | 183 | } |
| 181 | return nil | 184 | return nil | ... | ... |
-
Please register or sign in to post a comment