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
f4867aad
Commit
f4867aad
authored
Aug 15, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #744 from lei-cao/develop
ajax refresh gc message
parents
7d1b03ee
17006cfb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
admin.go
admin.go
+29
-2
adminui.go
adminui.go
+27
-2
No files found.
admin.go
View file @
f4867aad
...
...
@@ -11,6 +11,7 @@ package beego
import
(
"bytes"
"encoding/json"
"fmt"
"net/http"
"text/template"
...
...
@@ -59,6 +60,7 @@ func init() {
func
adminIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
indexTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
data
:=
make
(
map
[
interface
{}]
interface
{})
tmpl
.
Execute
(
rw
,
data
)
}
...
...
@@ -68,6 +70,7 @@ func adminIndex(rw http.ResponseWriter, r *http.Request) {
func
qpsIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
qpsTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
data
:=
make
(
map
[
interface
{}]
interface
{})
data
[
"Content"
]
=
toolbox
.
StatisticsMap
.
GetMap
()
...
...
@@ -127,6 +130,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
configTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
data
[
"Content"
]
=
m
...
...
@@ -158,6 +162,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
data
[
"Title"
]
=
"Routers"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
routerAndFilterTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
case
"filter"
:
resultList
:=
new
([][]
string
)
...
...
@@ -250,6 +255,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
data
[
"Title"
]
=
"Filters"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
routerAndFilterTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
default
:
...
...
@@ -302,16 +308,35 @@ func printTree(resultList *[][]string, t *Tree) {
func
profIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
r
.
ParseForm
()
command
:=
r
.
Form
.
Get
(
"command"
)
data
:=
make
(
map
[
interface
{}]
interface
{})
format
:=
r
.
Form
.
Get
(
"format"
)
data
:=
make
(
map
[
string
]
interface
{})
var
result
bytes
.
Buffer
if
command
!=
""
{
toolbox
.
ProcessInput
(
command
,
&
result
)
data
[
"Content"
]
=
result
.
String
()
data
[
"Title"
]
=
command
if
format
==
"json"
&&
command
==
"gc summary"
{
dataJson
,
err
:=
json
.
Marshal
(
data
)
if
err
!=
nil
{
http
.
Error
(
rw
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
}
rw
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
rw
.
Write
(
dataJson
)
return
}
data
[
"Title"
]
=
command
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
profillingTpl
))
if
command
==
"gc summary"
{
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
gcAjaxTpl
))
}
else
{
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
}
tmpl
.
Execute
(
rw
,
data
)
}
else
{
}
...
...
@@ -353,6 +378,7 @@ func healthcheck(rw http.ResponseWriter, req *http.Request) {
data
[
"Title"
]
=
"Health Check"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
healthCheckTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
}
...
...
@@ -401,6 +427,7 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
data
[
"Title"
]
=
"Tasks"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
tasksTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
}
...
...
adminui.go
View file @
f4867aad
...
...
@@ -27,11 +27,35 @@ For detail usage please check our document:
var
profillingTpl
=
`
{{define "content"}}
<h1>{{.Title}}</h1>
<pre>
{{.Content}}
<pre
id="content"
>
<div>{{.Content}}</div>
</pre>
{{end}}`
var
defaultScriptsTpl
=
``
var
gcAjaxTpl
=
`
{{define "scripts"}}
<script type="text/javascript">
var app = app || {};
(function() {
app.$el = $('#content');
app.getGc = function() {
var that = this;
$.ajax("/prof?command=gc%20summary&format=json").done(function(data) {
that.$el.append($('<p>' + data.Content + '</p>'));
});
};
$(document).ready(function() {
setInterval(function() {
app.getGc();
}, 3000);
});
})();
</script>
{{end}}
`
var
qpsTpl
=
`
{{define "content"}}
<h1>Requests statistics</h1>
...
...
@@ -311,6 +335,7 @@ Healthcheck
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
{{template "scripts" .}}
</body>
</html>
`
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