Software / code / prosody
Comparison
core/modulemanager.lua @ 1960:1e674dae31ae
modulemanager: Re-organise module loading to still work when no global modules_enabled is defined in the config (thanks hoelzro for accidentally discovering this one)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 16 Oct 2009 22:12:46 +0100 |
| parent | 1946:0eb3835ef9bf |
| child | 1986:d4ba9d94eb74 |
comparison
equal
deleted
inserted
replaced
| 1959:f56670ce64de | 1960:1e674dae31ae |
|---|---|
| 54 | 54 |
| 55 local NULL = {}; | 55 local NULL = {}; |
| 56 | 56 |
| 57 -- Load modules when a host is activated | 57 -- Load modules when a host is activated |
| 58 function load_modules_for_host(host) | 58 function load_modules_for_host(host) |
| 59 local disabled_set = {}; | |
| 60 local modules_disabled = config.get(host, "core", "modules_disabled"); | |
| 61 if modules_disabled then | |
| 62 for _, module in ipairs(modules_disabled) do | |
| 63 disabled_set[module] = true; | |
| 64 end | |
| 65 end | |
| 66 | |
| 67 -- Load auto-loaded modules for this host | |
| 68 for _, module in ipairs(autoload_modules) do | |
| 69 if not disabled_set[module] then | |
| 70 load(host, module); | |
| 71 end | |
| 72 end | |
| 73 | |
| 74 -- Load modules from global section | |
| 59 if config.get(host, "core", "load_global_modules") ~= false then | 75 if config.get(host, "core", "load_global_modules") ~= false then |
| 60 -- Load modules from global section | |
| 61 local modules_enabled = config.get("*", "core", "modules_enabled"); | 76 local modules_enabled = config.get("*", "core", "modules_enabled"); |
| 62 local modules_disabled = config.get(host, "core", "modules_disabled"); | |
| 63 local disabled_set = {}; | |
| 64 if modules_enabled then | 77 if modules_enabled then |
| 65 if modules_disabled then | |
| 66 for _, module in ipairs(modules_disabled) do | |
| 67 disabled_set[module] = true; | |
| 68 end | |
| 69 end | |
| 70 for _, module in ipairs(autoload_modules) do | |
| 71 if not disabled_set[module] then | |
| 72 load(host, module); | |
| 73 end | |
| 74 end | |
| 75 for _, module in ipairs(modules_enabled) do | 78 for _, module in ipairs(modules_enabled) do |
| 76 if not disabled_set[module] and not is_loaded(host, module) then | 79 if not disabled_set[module] and not is_loaded(host, module) then |
| 77 load(host, module); | 80 load(host, module); |
| 78 end | 81 end |
| 79 end | 82 end |