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

remove redundancy code and add port confict tip

This commit is contained in:
maxin[马鑫] 2016-04-26 10:16:53 +08:00
parent 88c5dfa6ea
commit 5402c753fb

4
app.go
View File

@ -137,12 +137,14 @@ func (app *App) Run() {
} }
// run normal mode // run normal mode
app.Server.Addr = addr
if BConfig.Listen.EnableHTTPS { if BConfig.Listen.EnableHTTPS {
go func() { go func() {
time.Sleep(20 * time.Microsecond) time.Sleep(20 * time.Microsecond)
if BConfig.Listen.HTTPSPort != 0 { if BConfig.Listen.HTTPSPort != 0 {
app.Server.Addr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort) app.Server.Addr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
} else if BConfig.Listen.EnableHTTP {
BeeLogger.Info("Start https server error, confict with http.Please reset https port")
return
} }
BeeLogger.Info("https server Running on %s", app.Server.Addr) BeeLogger.Info("https server Running on %s", app.Server.Addr)
if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil { if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil {