# HG changeset patch # User Waqas Hussain # Date 1289401055 -18000 # Node ID 8090880f0e180f5d9bb9c2ef86c17e17c08b1bb9 # Parent bbeba9f2acf8c91bcf4f821914daa614b8e46720 hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager. diff -r bbeba9f2acf8 -r 8090880f0e18 core/componentmanager.lua --- a/core/componentmanager.lua Wed Nov 10 19:54:38 2010 +0500 +++ b/core/componentmanager.lua Wed Nov 10 19:57:35 2010 +0500 @@ -34,28 +34,6 @@ end end -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] = create_component(host); - components[host] = default_component_handler; - 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 - fire_event("component-activated", host, host_config); - log("debug", "Activated %s component: %s", host_config.core.component_module, host); - end - end - end -end - -if prosody and prosody.events then - prosody.events.add_handler("server-starting", load_enabled_components); -end - function create_component(host, component, events) -- TODO check for host well-formedness return { type = "component", host = host, s2sout = {}, diff -r bbeba9f2acf8 -r 8090880f0e18 core/hostmanager.lua --- a/core/hostmanager.lua Wed Nov 10 19:54:38 2010 +0500 +++ b/core/hostmanager.lua Wed Nov 10 19:57:35 2010 +0500 @@ -32,8 +32,10 @@ local activated_any_host; for host, host_config in pairs(defined_hosts) do - if host ~= "*" and host_config.core.enabled ~= false and not host_config.core.component_module then - activated_any_host = true; + if host ~= "*" and host_config.core.enabled ~= false then + if not host_config.core.component_module then + activated_any_host = true; + end activate(host, host_config); end end @@ -49,6 +51,7 @@ prosody_events.add_handler("server-starting", load_enabled_hosts); function activate(host, host_config) + if hosts[host] then return nil, "host-already-exists"; end local host_session = { host = host; s2sout = {}; @@ -74,6 +77,7 @@ log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host); prosody_events.fire_event("host-activated", host, host_config); + return true; end function deactivate(host, reason)