# HG changeset patch # User Matthew Wild # Date 1228536213 0 # Node ID f6555ebf84ec22ecc884aa68422338d4ebecdb31 # Parent b2d665689df7805f3950e952f1cf0d86235ec43e Move module loading to modulemanager diff -r b2d665689df7 -r f6555ebf84ec core/modulemanager.lua --- a/core/modulemanager.lua Sat Dec 06 03:42:21 2008 +0000 +++ b/core/modulemanager.lua Sat Dec 06 04:03:33 2008 +0000 @@ -25,6 +25,7 @@ local log = logger.init("modulemanager"); local addDiscoInfoHandler = require "core.discomanager".addDiscoInfoHandler; local eventmanager = require "core.eventmanager"; +local config = require "core.configmanager"; local loadfile, pcall = loadfile, pcall; @@ -49,6 +50,17 @@ local modulehelpers = setmetatable({}, { __index = _G }); +-- Load modules when a host is activated +function load_modules_for_host(host) + local modules_enabled = config.get(host, "core", "modules_enabled"); + if modules_enabled then + for _, module in pairs(modules_enabled) do + load(host, module); + end + end +end +eventmanager.add_event_hook("host-activated", load_modules_for_host); +-- function load(host, module_name, config) if not (host and module_name) then diff -r b2d665689df7 -r f6555ebf84ec prosody --- a/prosody Sat Dec 06 03:42:21 2008 +0000 +++ b/prosody Sat Dec 06 04:03:33 2008 +0000 @@ -135,18 +135,6 @@ eventmanager.fire_event("server-starting"); --- Initialise modules - -for host in pairs(hosts) do - if host ~= "*" then - local modules_enabled = config.get(host, "core", "modules_enabled"); - if modules_enabled then - for _, module in pairs(modules_enabled) do - modulemanager.load(host, module); - end - end - end -end -- setup error handling setmetatable(_G, { __index = function (t, k) print("WARNING: ATTEMPT TO READ A NIL GLOBAL!!!", k); error("Attempt to read a non-existent global. Naughty boy.", 2); end, __newindex = function (t, k, v) print("ATTEMPT TO SET A GLOBAL!!!!", tostring(k).." = "..tostring(v)); error("Attempt to set a global. Naughty boy.", 2); end }) --]][][[]][];