Changeset

573:f6555ebf84ec

Move module loading to modulemanager
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Dec 2008 04:03:33 +0000 (2008-12-06)
parents 572:b2d665689df7
children 574:5963b780775d 578:5879264e28e2
files core/modulemanager.lua prosody
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 }) --]][][[]][];