Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 13338:470ab6b55e93
mod_admin_shell: Fix lint [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 21 Nov 2023 22:18:42 +0100 |
parent | 13334:aefcb6b4f47d |
child | 13349:d5d4e386c6fb |
comparison
equal
deleted
inserted
replaced
13337:5e258164d214 | 13338:470ab6b55e93 |
---|---|
2015 return true; | 2015 return true; |
2016 end | 2016 end |
2017 | 2017 |
2018 function def_env.debug:async(runner_id) | 2018 function def_env.debug:async(runner_id) |
2019 local print = self.session.print; | 2019 local print = self.session.print; |
2020 local async = require "prosody.util.async"; | 2020 local time_now = time.now(); |
2021 local time_now = require "prosody.util.time".now(); | |
2022 | |
2023 local function format_time(t) | |
2024 return os.date("%F %T", math.floor(normalize_time(t))); | |
2025 end | |
2026 | 2021 |
2027 if runner_id then | 2022 if runner_id then |
2028 local matched; | |
2029 for runner, since in pairs(async.waiting_runners) do | 2023 for runner, since in pairs(async.waiting_runners) do |
2030 if runner.id == runner_id then | 2024 if runner.id == runner_id then |
2031 matched = runner; | |
2032 print("ID ", runner.id); | 2025 print("ID ", runner.id); |
2033 local f = runner.func; | 2026 local f = runner.func; |
2034 if f == async.default_runner_func then | 2027 if f == async.default_runner_func then |
2035 print("Function ", tostring(runner.current_item).." (from work queue)"); | 2028 print("Function ", tostring(runner.current_item).." (from work queue)"); |
2036 else | 2029 else |
2037 print("Function ", tostring(f)); | 2030 print("Function ", tostring(f)); |
2038 if st.is_stanza(runner.current_item) then | 2031 if st.is_stanza(runner.current_item) then |
2039 print("Stanza:") | 2032 print("Stanza:") |
2040 print("\t"..runner.current_item:indent(2):pretty_print()); | 2033 print("\t"..runner.current_item:indent(2):pretty_print()); |
2041 else | 2034 else |
2042 print("Work item", serialize(runner.current_item, "debug")); | 2035 print("Work item", self.session.serialize(runner.current_item, "debug")); |
2043 end | 2036 end |
2044 end | 2037 end |
2045 | 2038 |
2046 print("Coroutine ", tostring(runner.thread).." ("..coroutine.status(runner.thread)..")"); | 2039 print("Coroutine ", tostring(runner.thread).." ("..coroutine.status(runner.thread)..")"); |
2047 print("Since ", since); | 2040 print("Since ", since); |
2052 end | 2045 end |
2053 end | 2046 end |
2054 return nil, "Runner not found or is currently idle"; | 2047 return nil, "Runner not found or is currently idle"; |
2055 end | 2048 end |
2056 | 2049 |
2057 local row = format_table({ { title = "ID", width = 12 }, { title = "Function", width = "10p" }, { title = "Status", width = "16" }, { title = "Location", width = "10p" } }, self.session.width); | 2050 local row = format_table({ |
2051 { title = "ID"; width = 12 }; | |
2052 { title = "Function"; width = "10p" }; | |
2053 { title = "Status"; width = "16" }; | |
2054 { title = "Location"; width = "10p" }; | |
2055 }, self.session.width); | |
2058 print(row()) | 2056 print(row()) |
2059 | 2057 |
2060 local c = 0; | 2058 local c = 0; |
2061 for runner, since in pairs(async.waiting_runners) do | 2059 for runner, since in pairs(async.waiting_runners) do |
2062 c = c + 1; | 2060 c = c + 1; |