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
c967f2d6
Commit
c967f2d6
authored
Dec 27, 2012
by
xiemengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pprof support
parent
d80ba7b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
beego.go
beego.go
+11
-0
pprof.go
pprof.go
+22
-0
No files found.
beego.go
View file @
c967f2d6
...
@@ -16,6 +16,7 @@ var (
...
@@ -16,6 +16,7 @@ var (
HttpPort
int
HttpPort
int
RecoverPanic
bool
RecoverPanic
bool
AutoRender
bool
AutoRender
bool
PprofOn
bool
ViewsPath
string
ViewsPath
string
RunMode
string
//"dev" or "prod"
RunMode
string
//"dev" or "prod"
AppConfig
*
Config
AppConfig
*
Config
...
@@ -35,6 +36,7 @@ func init() {
...
@@ -35,6 +36,7 @@ func init() {
RunMode
=
"prod"
//default runmod
RunMode
=
"prod"
//default runmod
AutoRender
=
true
AutoRender
=
true
RecoverPanic
=
true
RecoverPanic
=
true
PprofOn
=
false
ViewsPath
=
"views"
ViewsPath
=
"views"
}
else
{
}
else
{
HttpAddr
=
AppConfig
.
String
(
"httpaddr"
)
HttpAddr
=
AppConfig
.
String
(
"httpaddr"
)
...
@@ -59,6 +61,11 @@ func init() {
...
@@ -59,6 +61,11 @@ func init() {
}
else
{
}
else
{
RecoverPanic
=
ar
RecoverPanic
=
ar
}
}
if
ar
,
err
:=
AppConfig
.
Bool
(
"pprofon"
);
err
!=
nil
{
PprofOn
=
false
}
else
{
PprofOn
=
ar
}
if
views
:=
AppConfig
.
String
(
"viewspath"
);
views
==
""
{
if
views
:=
AppConfig
.
String
(
"viewspath"
);
views
==
""
{
ViewsPath
=
"views"
ViewsPath
=
"views"
}
else
{
}
else
{
...
@@ -147,5 +154,9 @@ func FilterPrefixPath(path string, filter http.HandlerFunc) *App {
...
@@ -147,5 +154,9 @@ func FilterPrefixPath(path string, filter http.HandlerFunc) *App {
}
}
func
Run
()
{
func
Run
()
{
if
PprofOn
{
BeeApp
.
RegisterController
(
`/debug/pprof`
,
&
ProfController
{})
BeeApp
.
RegisterController
(
`/debug/pprof/:pp([\w+])`
,
&
ProfController
{})
}
BeeApp
.
Run
()
BeeApp
.
Run
()
}
}
pprof.go
0 → 100644
View file @
c967f2d6
package
beego
import
(
"net/http/pprof"
)
type
ProfController
struct
{
Controller
}
func
(
this
*
ProfController
)
Get
()
{
ptype
:=
this
.
Ctx
.
Params
[
":pp"
]
if
ptype
==
""
{
pprof
.
Index
(
this
.
Ctx
.
ResponseWriter
,
this
.
Ctx
.
Request
)
}
else
if
ptype
==
"cmdline"
{
pprof
.
Cmdline
(
this
.
Ctx
.
ResponseWriter
,
this
.
Ctx
.
Request
)
}
else
if
ptype
==
"profile"
{
pprof
.
Profile
(
this
.
Ctx
.
ResponseWriter
,
this
.
Ctx
.
Request
)
}
else
if
ptype
==
"symbol"
{
pprof
.
Symbol
(
this
.
Ctx
.
ResponseWriter
,
this
.
Ctx
.
Request
)
}
}
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