Software /
code /
prosody
Diff
plugins/mod_admin_telnet.lua @ 9009:4c745d42c974
mod_admin_telnet: Rename timer:info() -> debug:timers()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 10 Jul 2018 21:08:32 +0100 |
parent | 8964:76780f37028d |
child | 9330:36badabc85ce |
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua Tue Jul 10 22:04:26 2018 +0200 +++ b/plugins/mod_admin_telnet.lua Tue Jul 10 21:08:32 2018 +0100 @@ -336,43 +336,6 @@ return true, "OK"; end -def_env.timer = {}; - -function def_env.timer:info() - local socket = require "socket"; - local print = self.session.print; - local add_task = require"util.timer".add_task; - local h, params = add_task.h, add_task.params; - if h then - print("-- util.timer"); - for i, id in ipairs(h.ids) do - if not params[id] then - print(os.date("%F %T", h.priorities[i]), h.items[id]); - elseif not params[id].callback then - print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id])); - else - print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id])); - end - end - end - if server.event_base then - local count = 0; - for k, v in pairs(debug.getregistry()) do - if type(v) == "function" and v.callback and v.callback == add_task._on_timer then - count = count + 1; - end - end - print(count .. " libevent callbacks"); - end - if h then - local next_time = h:peek(); - if next_time then - return true, os.date("Next event at %F %T (in %%.6fs)", next_time):format(next_time - socket.gettime()); - end - end - return true; -end - def_env.module = {}; local function get_hosts_set(hosts, module) @@ -1189,6 +1152,44 @@ return true, helpers.show_events(events_obj, event); end +function def_env.debug:timers(filter) + local socket = require "socket"; + local print = self.session.print; + local add_task = require"util.timer".add_task; + local h, params = add_task.h, add_task.params; + if h then + print("-- util.timer"); + for i, id in ipairs(h.ids) do + if not params[id] then + print(os.date("%F %T", h.priorities[i]), h.items[id]); + elseif not params[id].callback then + print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id])); + else + print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id])); + end + end + end + if server.event_base then + local count = 0; + for k, v in pairs(debug.getregistry()) do + if type(v) == "function" and v.callback and v.callback == add_task._on_timer then + count = count + 1; + end + end + print(count .. " libevent callbacks"); + end + if h then + local next_time = h:peek(); + if next_time then + return true, os.date("Next event at %F %T (in %%.6fs)", next_time):format(next_time - socket.gettime()); + end + end + return true; +end + +-- COMPAT: debug:timers() was timer:info() for some time in trunk +def_env.timer = { info = def_env.debug.timers }; + module:hook("server-stopping", function(event) for conn, session in pairs(sessions) do session.print("Shutting down: "..(event.reason or "unknown reason"));