+
+function load_enabled_components(config)
+ local defined_hosts = config or configmanager.getconfig();
+
+ for host, host_config in pairs(defined_hosts) do
+ if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
+ hosts[host] = { type = "component", host = host, connected = true, s2sout = {} };
+ modulemanager.load(host, "dialback");
+ local ok, err = modulemanager.load(host, host_config.core.component_module);
+ if not ok then
+ log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
+ else
+ log("info", "Activated %s component: %s", host_config.core.component_module, host);
+ end
+
+ local ok, component_handler = modulemanager.call_module_method(modulemanager.get_module(host, host_config.core.component_module), "load_component");
+ if not ok then
+ log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(component_handler));
+ else
+ components[host] = component_handler;
+ end
+ end
+ end
+end
+
+eventmanager.add_event_hook("server-starting", load_enabled_components);