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

beego: move init to a fund & add a new fund TestBeegoInit

support Test with everything init
This commit is contained in:
asta.xie 2014-04-03 15:07:20 +08:00
parent 12e1ab0f80
commit 5505cc09ed

View File

@ -2,6 +2,7 @@ package beego
import ( import (
"net/http" "net/http"
"os"
"path" "path"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -174,6 +175,16 @@ func AddAPPStartHook(hf hookfunc) {
// Run beego application. // Run beego application.
// it's alias of App.Run. // it's alias of App.Run.
func Run() { func Run() {
initBeforeHttpRun()
if EnableAdmin {
go BeeAdminApp.Run()
}
BeeApp.Run()
}
func initBeforeHttpRun() {
// if AppConfigPath not In the conf/app.conf reParse config // if AppConfigPath not In the conf/app.conf reParse config
if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") { if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") {
err := ParseConfig() err := ParseConfig()
@ -222,12 +233,13 @@ func Run() {
middleware.VERSION = VERSION middleware.VERSION = VERSION
middleware.AppName = AppName middleware.AppName = AppName
middleware.RegisterErrorHandler() middleware.RegisterErrorHandler()
}
if EnableAdmin { func TestBeegoInit(apppath string) {
go BeeAdminApp.Run() AppPath = apppath
} AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
os.Chdir(AppPath)
BeeApp.Run() initBeforeHttpRun()
} }
func init() { func init() {