Mercurial > prosody-hg
comparison core/modulemanager.lua @ 10411:db2a06b9ff98
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 16 Nov 2019 16:52:31 +0100 |
| parents | f36f7d2c269b |
| children | 8f709577fe8e |
comparison
equal
deleted
inserted
replaced
| 10410:659b577f280c | 10411:db2a06b9ff98 |
|---|---|
| 21 local xpcall = require "util.xpcall".xpcall; | 21 local xpcall = require "util.xpcall".xpcall; |
| 22 local debug_traceback = debug.traceback; | 22 local debug_traceback = debug.traceback; |
| 23 local setmetatable, rawget = setmetatable, rawget; | 23 local setmetatable, rawget = setmetatable, rawget; |
| 24 local ipairs, pairs, type, t_insert = ipairs, pairs, type, table.insert; | 24 local ipairs, pairs, type, t_insert = ipairs, pairs, type, table.insert; |
| 25 | 25 |
| 26 local autoload_modules = {prosody.platform, "presence", "message", "iq", "offline", "c2s", "s2s", "s2s_auth_certs"}; | 26 local autoload_modules = { |
| 27 local component_inheritable_modules = {"tls", "saslauth", "dialback", "iq", "s2s"}; | 27 prosody.platform, |
| 28 "presence", | |
| 29 "message", | |
| 30 "iq", | |
| 31 "offline", | |
| 32 "c2s", | |
| 33 "s2s", | |
| 34 "s2s_auth_certs", | |
| 35 }; | |
| 36 local component_inheritable_modules = { | |
| 37 "tls", | |
| 38 "saslauth", | |
| 39 "dialback", | |
| 40 "iq", | |
| 41 "s2s", | |
| 42 "s2s_bidi", | |
| 43 }; | |
| 28 | 44 |
| 29 -- We need this to let modules access the real global namespace | 45 -- We need this to let modules access the real global namespace |
| 30 local _G = _G; | 46 local _G = _G; |
| 31 | 47 |
| 32 local _ENV = nil; | 48 local _ENV = nil; |
| 167 api_instance.environment = pluginenv; | 183 api_instance.environment = pluginenv; |
| 168 | 184 |
| 169 local mod, err = pluginloader.load_code(module_name, nil, pluginenv); | 185 local mod, err = pluginloader.load_code(module_name, nil, pluginenv); |
| 170 if not mod then | 186 if not mod then |
| 171 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | 187 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
| 188 api_instance:set_status("error", "Failed to load (see log)"); | |
| 172 return nil, err; | 189 return nil, err; |
| 173 end | 190 end |
| 174 | 191 |
| 175 api_instance.path = err; | 192 api_instance.path = err; |
| 176 | 193 |
| 180 -- Call module's "load" | 197 -- Call module's "load" |
| 181 if module_has_method(pluginenv, "load") then | 198 if module_has_method(pluginenv, "load") then |
| 182 ok, err = call_module_method(pluginenv, "load"); | 199 ok, err = call_module_method(pluginenv, "load"); |
| 183 if not ok then | 200 if not ok then |
| 184 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); | 201 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); |
| 202 api_instance:set_status("warn", "Error during load (see log)"); | |
| 185 end | 203 end |
| 186 end | 204 end |
| 187 api_instance.reloading, api_instance.saved_state = nil, nil; | 205 api_instance.reloading, api_instance.saved_state = nil, nil; |
| 188 | 206 |
| 189 if api_instance.host == "*" then | 207 if api_instance.host == "*" then |
| 202 end | 220 end |
| 203 end | 221 end |
| 204 if not ok then | 222 if not ok then |
| 205 modulemap[api_instance.host][module_name] = nil; | 223 modulemap[api_instance.host][module_name] = nil; |
| 206 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); | 224 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); |
| 225 api_instance:set_status("warn", "Error during load (see log)"); | |
| 226 else | |
| 227 api_instance:set_status("core", "Loaded", false); | |
| 207 end | 228 end |
| 208 return ok and pluginenv, err; | 229 return ok and pluginenv, err; |
| 209 end | 230 end |
| 210 | 231 |
| 211 local function do_reload_module(host, name) | 232 local function do_reload_module(host, name) |
