summaryrefslogtreecommitdiff
path: root/server-beta/src/service/service.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/service/service.lua')
-rw-r--r--server-beta/src/service/service.lua38
1 files changed, 30 insertions, 8 deletions
diff --git a/server-beta/src/service/service.lua b/server-beta/src/service/service.lua
index 3712b7b8..fb7200b8 100644
--- a/server-beta/src/service/service.lua
+++ b/server-beta/src/service/service.lua
@@ -7,14 +7,35 @@ local proto = require 'proto'
local m = {}
m.type = 'service'
-function m.listenPub()
- task.create(function ()
- while true do
- pub.checkDead()
- pub.recieve()
- task.sleep(0)
- end
+function m.reportMemory()
+ local mems = {}
+ local totalMem = 0
+ mems[0] = collectgarbage 'count'
+ totalMem = totalMem + collectgarbage 'count'
+ for id, brave in ipairs(pub.braves) do
+ mems[id] = brave.memory
+ totalMem = totalMem + brave.memory
+ end
+
+ local lines = {}
+ lines[#lines+1] = ' --------------- Memory ---------------'
+ lines[#lines+1] = (' Total: %.3f MB'):format(totalMem / 1000.0)
+ for i = 0, #mems do
+ lines[#lines+1] = (' # %02d : %.3f MB'):format(i, mems[i] / 1000.0)
+ end
+ return table.concat(lines, '\n')
+end
+
+function m.report()
+ local t = timer.loop(60.0, function ()
+ local lines = {}
+ lines[#lines+1] = '========= Medical Examination Report ========='
+ lines[#lines+1] = m.reportMemory()
+ lines[#lines+1] = '=============================================='
+
+ log.debug(table.concat(lines, '\n'))
end)
+ t:onTimer()
end
function m.startTimer()
@@ -32,7 +53,8 @@ function m.start()
pub.recruitBraves(4)
task.setErrorHandle(log.error)
proto.listen()
- m.listenPub()
+ pub.listen()
+ m.report()
m.startTimer()
end