Comparison

core/modulemanager.lua @ 10434:8f709577fe8e

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 23 Nov 2019 23:12:01 +0100
parent 10433:7777f25d5266
parent 10288:f36f7d2c269b
child 10530:67d56dacc79c
comparison
equal deleted inserted replaced
10433:7777f25d5266 10434:8f709577fe8e
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;
172 api_instance.environment = pluginenv; 188 api_instance.environment = pluginenv;
173 189
174 local mod, err = pluginloader.load_code(module_name, nil, pluginenv); 190 local mod, err = pluginloader.load_code(module_name, nil, pluginenv);
175 if not mod then 191 if not mod then
176 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); 192 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
193 api_instance:set_status("error", "Failed to load (see log)");
177 return nil, err; 194 return nil, err;
178 end 195 end
179 196
180 api_instance.path = err; 197 api_instance.path = err;
181 198
185 -- Call module's "load" 202 -- Call module's "load"
186 if module_has_method(pluginenv, "load") then 203 if module_has_method(pluginenv, "load") then
187 ok, err = call_module_method(pluginenv, "load"); 204 ok, err = call_module_method(pluginenv, "load");
188 if not ok then 205 if not ok then
189 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil"); 206 log("warn", "Error loading module '%s' on '%s': %s", module_name, host, err or "nil");
207 api_instance:set_status("warn", "Error during load (see log)");
190 end 208 end
191 end 209 end
192 api_instance.reloading, api_instance.saved_state = nil, nil; 210 api_instance.reloading, api_instance.saved_state = nil, nil;
193 211
194 if api_instance.host == "*" then 212 if api_instance.host == "*" then
207 end 225 end
208 end 226 end
209 if not ok then 227 if not ok then
210 modulemap[api_instance.host][module_name] = nil; 228 modulemap[api_instance.host][module_name] = nil;
211 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); 229 log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil");
230 api_instance:set_status("warn", "Error during load (see log)");
231 else
232 api_instance:set_status("core", "Loaded", false);
212 end 233 end
213 return ok and pluginenv, err; 234 return ok and pluginenv, err;
214 end 235 end
215 236
216 local function do_reload_module(host, name) 237 local function do_reload_module(host, name)