Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
fe9c52fb
Commit
fe9c52fb
authored
Sep 07, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize init admin
parent
284dfc08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
beego.go
beego.go
+16
-20
hooks.go
hooks.go
+7
-0
No files found.
beego.go
View file @
fe9c52fb
...
...
@@ -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
()
}
hooks.go
View file @
fe9c52fb
...
...
@@ -98,3 +98,10 @@ func registerDocs() error {
}
return
nil
}
func
registerAdmin
()
error
{
if
EnableAdmin
{
go
beeAdminApp
.
Run
()
}
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment