Commit fe9c52fb authored by astaxie's avatar astaxie

optimize init admin

parent 284dfc08
......@@ -54,27 +54,9 @@ func Run(params ...string) {
}
}
if EnableAdmin {
go beeAdminApp.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() {
// if AppConfigPath not In the conf/app.conf reParse config
if AppConfigPath != filepath.Join(AppPath, "conf", "app.conf") {
......@@ -91,12 +73,26 @@ func initBeforeHttpRun() {
AddAPPStartHook(registerSession)
AddAPPStartHook(registerDocs)
AddAPPStartHook(registerTemplate)
AddAPPStartHook(registerAdmin)
// do hooks function
for _, hk := range hooks {
err := hk()
if err != nil {
if err := hk(); err != nil {
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()
}
......@@ -98,3 +98,10 @@ func registerDocs() error {
}
return nil
}
func registerAdmin() error {
if EnableAdmin {
go beeAdminApp.Run()
}
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment