Mercurial > prosody-hg
comparison core/modulemanager.lua @ 8916:e727747279a0
modulemanager: Expose function to get the list of modules that should be loaded on a host
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 20 Jun 2018 10:41:02 +0100 |
| parents | 9ddd0fbbe53a |
| children | acf74ad0b795 |
comparison
equal
deleted
inserted
replaced
| 8915:2502be210a85 | 8916:e727747279a0 |
|---|---|
| 44 local get_modules, is_loaded, module_has_method, call_module_method; | 44 local get_modules, is_loaded, module_has_method, call_module_method; |
| 45 | 45 |
| 46 -- [host] = { [module] = module_env } | 46 -- [host] = { [module] = module_env } |
| 47 local modulemap = { ["*"] = {} }; | 47 local modulemap = { ["*"] = {} }; |
| 48 | 48 |
| 49 -- Load modules when a host is activated | 49 -- Get the list of modules to be loaded on a host |
| 50 function load_modules_for_host(host) | 50 local function get_modules_for_host(host) |
| 51 local component = config.get(host, "component_module"); | 51 local component = config.get(host, "component_module"); |
| 52 | 52 |
| 53 local global_modules_enabled = config.get("*", "modules_enabled"); | 53 local global_modules_enabled = config.get("*", "modules_enabled"); |
| 54 local global_modules_disabled = config.get("*", "modules_disabled"); | 54 local global_modules_disabled = config.get("*", "modules_disabled"); |
| 55 local host_modules_enabled = config.get(host, "modules_enabled"); | 55 local host_modules_enabled = config.get(host, "modules_enabled"); |
| 69 log("error", "The mod_console plugin has been renamed to mod_admin_telnet. Please update your config."); | 69 log("error", "The mod_console plugin has been renamed to mod_admin_telnet. Please update your config."); |
| 70 modules:remove("console"); | 70 modules:remove("console"); |
| 71 modules:add("admin_telnet"); | 71 modules:add("admin_telnet"); |
| 72 end | 72 end |
| 73 | 73 |
| 74 if component then | 74 return modules, component; |
| 75 load(host, component); | 75 end |
| 76 | |
| 77 -- Load modules when a host is activated | |
| 78 function load_modules_for_host(host) | |
| 79 local modules, component_module = get_modules_for_host(host); | |
| 80 | |
| 81 -- Ensure component module is loaded first | |
| 82 if component_module then | |
| 83 load(host, component_module); | |
| 76 end | 84 end |
| 77 for module in modules do | 85 for module in modules do |
| 78 load(host, module); | 86 load(host, module); |
| 79 end | 87 end |
| 80 end | 88 end |
| 322 return false, "no-such-method"; | 330 return false, "no-such-method"; |
| 323 end | 331 end |
| 324 end | 332 end |
| 325 | 333 |
| 326 return { | 334 return { |
| 335 get_modules_for_host = get_modules_for_host; | |
| 327 load_modules_for_host = load_modules_for_host; | 336 load_modules_for_host = load_modules_for_host; |
| 328 load = load; | 337 load = load; |
| 329 unload = unload; | 338 unload = unload; |
| 330 reload = reload; | 339 reload = reload; |
| 331 get_module = get_module; | 340 get_module = get_module; |
