Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 11601:9483728f890f
mod_admin_shell: Add basic command that shows more info about loaded modules
To show info about loaded modules. Inspired by the desire to know
whether a module was loaded from the core set or 3rd party.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 12 Jun 2021 16:50:15 +0200 |
parent | 11523:5f15ab7c6ae5 |
child | 11602:78ec0741c2bc |
comparison
equal
deleted
inserted
replaced
11600:a02c277eb97a | 11601:9483728f890f |
---|---|
214 print [[s2s:close(from, to) - Close a connection from one domain to another]] | 214 print [[s2s:close(from, to) - Close a connection from one domain to another]] |
215 print [[s2s:closeall(host) - Close all the incoming/outgoing s2s sessions to specified host]] | 215 print [[s2s:closeall(host) - Close all the incoming/outgoing s2s sessions to specified host]] |
216 elseif section == "http" then | 216 elseif section == "http" then |
217 print [[http:list(hosts) - Show HTTP endpoints]] | 217 print [[http:list(hosts) - Show HTTP endpoints]] |
218 elseif section == "module" then | 218 elseif section == "module" then |
219 print [[module:info(module, host) - Show information about a loaded module]] | |
219 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] | 220 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]] |
220 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] | 221 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]] |
221 print [[module:unload(module, host) - The same, but just unloads the module from memory]] | 222 print [[module:unload(module, host) - The same, but just unloads the module from memory]] |
222 print [[module:list(host) - List the modules loaded on the specified host]] | 223 print [[module:list(host) - List the modules loaded on the specified host]] |
223 elseif section == "host" then | 224 elseif section == "host" then |
390 hosts_set:add("*"); | 391 hosts_set:add("*"); |
391 end | 392 end |
392 return hosts_set; | 393 return hosts_set; |
393 end | 394 end |
394 | 395 |
396 function def_env.module:info(name, hosts) | |
397 if not name then | |
398 return nil, "module name expected"; | |
399 end | |
400 local print = self.session.print; | |
401 hosts = get_hosts_with_module(hosts, name); | |
402 if hosts:empty() then | |
403 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; | |
404 end | |
405 | |
406 for host in hosts do | |
407 local mod = modulemanager.get_module(host, name); | |
408 if mod.module.host == "*" then | |
409 print("in global context"); | |
410 elseif mod.module:get_host_type() == "local" then | |
411 print("on VirtualHost " .. mod.module.host); | |
412 elseif mod.module:get_host_type() == "component" then | |
413 local component_type = module:context(host):get_option_string("component_module", type); | |
414 if component_type == "component" then | |
415 component_type = "external"; | |
416 end | |
417 print("on " .. component_type .. " Component " .. mod.module.host); | |
418 end | |
419 print(" path: " .. (mod.module.path or "n/a")); | |
420 end | |
421 return true; | |
422 end | |
423 | |
395 function def_env.module:load(name, hosts, config) | 424 function def_env.module:load(name, hosts, config) |
396 hosts = get_hosts_with_module(hosts); | 425 hosts = get_hosts_with_module(hosts); |
397 | 426 |
398 -- Load the module for each host | 427 -- Load the module for each host |
399 local ok, err, count, mod = true, nil, 0; | 428 local ok, err, count, mod = true, nil, 0; |