Skip to content

Commit

Permalink
Add infos
Browse files Browse the repository at this point in the history
  • Loading branch information
javalikescript committed Jan 25, 2025
1 parent 4a3783d commit c4cadf4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions/https/https.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ local function closeServer()
end
end

function extension:getHTTPServer()
return httpSecureServer
end

extension:subscribeEvent('startup', function()
local configuration = extension:getConfiguration()
closeServer()
Expand Down
7 changes: 7 additions & 0 deletions extensions/web-base/web-base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ function extension:unregisterAddonExtension(ext)
self:registerAddon(ext:getId())
end

function extension:getWebBaseInfo()
return {
addons = Map.size(addons),
websockets = #websockets
}
end

extension:watchPattern('^data/.*', onDataChange)

extension:subscribeEvent('startup', function()
Expand Down
7 changes: 7 additions & 0 deletions lha/restEngine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ local REST_ADMIN = {
local engine = exchange:getAttribute('engine')
local httpServer = engine:getHTTPServer()
--local ip, port = httpServer:getAddress()
local httpsExt = engine:getExtensionById('https')
local httpsServer = httpsExt and httpsExt:getHTTPServer()
local webBaseExt = engine:getExtensionById('web-base')
local webBaseInfo = webBaseExt and webBaseExt:getWebBaseInfo()
return {
['CPU Time'] = os.clock(),
['Server Time'] = os.time(),
Expand All @@ -262,6 +266,9 @@ local REST_ADMIN = {
['Lua Registry Entries'] = Map.size(debug.getregistry()),
['Loaded Packages'] = Map.size(package.loaded),
['HTTP Clients'] = Map.size(httpServer.pendings),
['HTTPS Clients'] = httpsServer and Map.size(httpsServer.pendings) or 0,
['Web Base Addons'] = webBaseInfo and webBaseInfo.addons or 0,
['Web Base WebSockets'] = webBaseInfo and webBaseInfo.websockets or 0,
}
end,
backup = {
Expand Down

0 comments on commit c4cadf4

Please sign in to comment.