Skip to content

Commit 91a44ad

Browse files
Enhance engine info
1 parent 93f68c8 commit 91a44ad

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

extensions/web-base/www/app.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@
215215
<page-article>
216216
<p>Information</p>
217217
<dl>
218-
<dt><label>CPU Time</label></dt><dd><span v-html="clock">na</span></dd>
219-
<dt><label>Memory size</label></dt><dd><span v-html="memory">na</span></dd>
220-
<dt><label>Server Time</label></dt><dd><span v-html="time">na</span></dd>
218+
<template v-for="(value, name) in infos">
219+
<dt><label>{{ name }}</label></dt>
220+
<dd><span>{{ value }}</span></dd>
221+
</template>
221222
</dl>
222223
</page-article>
223224
</app-page>

extensions/web-base/www/app/app.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,19 @@ var homePage = new Vue({
351351
new Vue({
352352
el: '#engineInfo',
353353
data: {
354-
clock: '...',
355-
memory: '...',
356-
time: '...'
354+
infos: {}
357355
},
358356
methods: {
359357
onShow: function() {
360358
var page = this;
361359
fetch('/engine/admin/info').then(function(response) {
362360
return response.json();
363361
}).then(function(data) {
364-
//console.log('fetch(admin/info)', data);
365-
page.clock = data.clock;
366-
page.memory = data.memory;
362+
console.log('fetch(admin/info)', data);
367363
var clientTime = Math.round(Date.now() / 1000);
368-
var delta = clientTime - data.time;
369-
page.time = '' + data.time + ' (' + delta + ')';
364+
var serverTime = data['Server Time'];
365+
data['Delta Time'] = clientTime - serverTime;
366+
page.infos = data;
370367
toaster.toast('Refreshed');
371368
});
372369
}

lha/restEngine.lua

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ local RestHttpHandler = require('jls.net.http.handler.RestHttpHandler')
77
local HttpExchange = require('jls.net.http.HttpExchange')
88
local json = require('jls.util.json')
99
local Date = require('jls.util.Date')
10+
local Map = require('jls.util.Map')
1011
local ZipFile = require('jls.util.zip.ZipFile')
1112

1213
local utils = require('lha.utils')
@@ -89,6 +90,7 @@ local REST_ADMIN = {
8990
['restart?method=POST'] = function(exchange)
9091
event:setTimeout(function()
9192
exchange.attributes.engine:stop()
93+
runtime.gc()
9294
exchange.attributes.engine:start()
9395
end, 100)
9496
return 'In progress'
@@ -105,21 +107,18 @@ local REST_ADMIN = {
105107
return 'Done'
106108
end,
107109
info = function(exchange)
108-
--local engine = exchange:getAttribute('engine')
109-
--local ip, port = engine:getHTTPServer():getAddress()
110+
local engine = exchange:getAttribute('engine')
111+
local httpServer = engine:getHTTPServer()
112+
--local ip, port = httpServer:getAddress()
110113
return {
111-
clock = os.clock(),
112-
memory = math.floor(collectgarbage('count') * 1024),
113-
time = Date.now() // 1000
114+
['CPU Time'] = os.clock(),
115+
['Server Time'] = os.time(),
116+
['Lua Memory Size'] = math.floor(collectgarbage('count') * 1024),
117+
['Lua Registry Entries'] = Map.size(debug.getregistry()),
118+
['Loaded Packages'] = Map.size(package.loaded),
119+
['HTTP Clients'] = Map.size(httpServer.pendings),
114120
}
115121
end,
116-
mem = function(exchange)
117-
local report = ''
118-
require('jls.util.memprof').printReport(function(data)
119-
report = data
120-
end, false, false, 'csv')
121-
return report
122-
end,
123122
backup = {
124123
['create?method=POST'] = function(exchange)
125124
local engine = exchange:getAttribute('engine')

0 commit comments

Comments
 (0)