Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
c967f2d6
authored
2012-12-27 22:27:26 +0800
by
xiemengjun
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add pprof support
1 parent
d80ba7b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
beego.go
pprof.go
beego.go
View file @
c967f2d
...
...
@@ -16,6 +16,7 @@ var (
HttpPort
int
RecoverPanic
bool
AutoRender
bool
PprofOn
bool
ViewsPath
string
RunMode
string
//"dev" or "prod"
AppConfig
*
Config
...
...
@@ -35,6 +36,7 @@ func init() {
RunMode
=
"prod"
//default runmod
AutoRender
=
true
RecoverPanic
=
true
PprofOn
=
false
ViewsPath
=
"views"
}
else
{
HttpAddr
=
AppConfig
.
String
(
"httpaddr"
)
...
...
@@ -59,6 +61,11 @@ func init() {
}
else
{
RecoverPanic
=
ar
}
if
ar
,
err
:=
AppConfig
.
Bool
(
"pprofon"
);
err
!=
nil
{
PprofOn
=
false
}
else
{
PprofOn
=
ar
}
if
views
:=
AppConfig
.
String
(
"viewspath"
);
views
==
""
{
ViewsPath
=
"views"
}
else
{
...
...
@@ -147,5 +154,9 @@ func FilterPrefixPath(path string, filter http.HandlerFunc) *App {
}
func
Run
()
{
if
PprofOn
{
BeeApp
.
RegisterController
(
`/debug/pprof`
,
&
ProfController
{})
BeeApp
.
RegisterController
(
`/debug/pprof/:pp([\w+])`
,
&
ProfController
{})
}
BeeApp
.
Run
()
}
...
...
pprof.go
0 → 100644
View file @
c967f2d
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
Styling with
Markdown
is supported
Attach a file
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 post a comment