mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 11:50:55 +00:00
optimize init admin
This commit is contained in:
parent
284dfc0843
commit
fe9c52fb69
36
beego.go
36
beego.go
@ -54,27 +54,9 @@ func Run(params ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if EnableAdmin {
|
|
||||||
go beeAdminApp.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
BeeApp.Run()
|
BeeApp.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function is for test package init
|
|
||||||
func TestBeegoInit(apppath string) {
|
|
||||||
AppPath = apppath
|
|
||||||
os.Setenv("BEEGO_RUNMODE", "test")
|
|
||||||
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
|
||||||
err := ParseConfig()
|
|
||||||
if err != nil && !os.IsNotExist(err) {
|
|
||||||
// for init if doesn't have app.conf will not panic
|
|
||||||
Info(err)
|
|
||||||
}
|
|
||||||
os.Chdir(AppPath)
|
|
||||||
initBeforeHttpRun()
|
|
||||||
}
|
|
||||||
|
|
||||||
func initBeforeHttpRun() {
|
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") {
|
||||||
@ -91,12 +73,26 @@ func initBeforeHttpRun() {
|
|||||||
AddAPPStartHook(registerSession)
|
AddAPPStartHook(registerSession)
|
||||||
AddAPPStartHook(registerDocs)
|
AddAPPStartHook(registerDocs)
|
||||||
AddAPPStartHook(registerTemplate)
|
AddAPPStartHook(registerTemplate)
|
||||||
|
AddAPPStartHook(registerAdmin)
|
||||||
|
|
||||||
// do hooks function
|
// do hooks function
|
||||||
for _, hk := range hooks {
|
for _, hk := range hooks {
|
||||||
err := hk()
|
if err := hk(); err != nil {
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function is for test package init
|
||||||
|
func TestBeegoInit(apppath string) {
|
||||||
|
AppPath = apppath
|
||||||
|
os.Setenv("BEEGO_RUNMODE", "test")
|
||||||
|
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
||||||
|
err := ParseConfig()
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
// for init if doesn't have app.conf will not panic
|
||||||
|
Info(err)
|
||||||
|
}
|
||||||
|
os.Chdir(AppPath)
|
||||||
|
initBeforeHttpRun()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user