aboutsummaryrefslogtreecommitdiffstats
path: root/prosody
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-12-06 03:41:49 +0000
committerMatthew Wild <mwild1@gmail.com>2008-12-06 03:41:49 +0000
commitdfeabed19fd81dabeb88477c716ecd4c132484c0 (patch)
treea5ccac952fd39818218b3f2e571f70545f52d142 /prosody
parentc0334a2ad92f5bff979f309a6276b067487c03a8 (diff)
downloadprosody-dfeabed19fd81dabeb88477c716ecd4c132484c0.tar.gz
prosody-dfeabed19fd81dabeb88477c716ecd4c132484c0.zip
Add hostmanager, and eventmanager
Diffstat (limited to 'prosody')
-rwxr-xr-xprosody79
1 files changed, 43 insertions, 36 deletions
diff --git a/prosody b/prosody
index 08b0d936..9fd5e4ff 100755
--- a/prosody
+++ b/prosody
@@ -68,29 +68,6 @@ do
end
end
-local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
-local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
-local _mkdir = {}
-function mkdir(path)
- path = path:gsub("/", path_separator);
- --print("mkdir",path);
- local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a");
-end
-function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
-function mkdirs(host)
- if not _mkdir[host] then
- local host_dir = string.format("%s/%s", data_path, encode(host));
- mkdir(host_dir);
- mkdir(host_dir.."/accounts");
- mkdir(host_dir.."/vcard");
- mkdir(host_dir.."/roster");
- mkdir(host_dir.."/private");
- mkdir(host_dir.."/offline");
- _mkdir[host] = true;
- end
-end
-mkdir(data_path);
-
require "util.datamanager".set_data_path(data_path);
local server = require "net.server"
@@ -101,14 +78,6 @@ require "util.dependencies"
sessions = {};
hosts = {};
-local defined_hosts = config.getconfig();
-
-for host, host_config in pairs(defined_hosts) do
- if host ~= "*" and (host_config.core.enabled == nil or host_config.core.enabled) then
- hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {} };
- mkdirs(host);
- end
-end
-- Load and initialise core modules --
@@ -116,6 +85,8 @@ require "util.import"
require "core.xmlhandlers"
require "core.rostermanager"
require "core.offlinemessage"
+require "core.eventmanager"
+require "core.hostmanager"
require "core.modulemanager"
require "core.usermanager"
require "core.sessionmanager"
@@ -126,12 +97,44 @@ pcall(require, "remdebug.engine");
if remdebug then remdebug.engine.start() end
]]
-local start = require "net.connlisteners".start;
+local cl = require "net.connlisteners";
+
require "util.stanza"
require "util.jid"
------------------------------------------------------------------------
+------------- Begin code without a home ---------------------
+
+local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
+local path_separator = "/"; if os.getenv("WINDIR") then path_separator = "\\" end
+local _mkdir = {}
+function mkdir(path)
+ path = path:gsub("/", path_separator);
+ --print("mkdir",path);
+ local x = io.popen("mkdir \""..path.."\" 2>&1"):read("*a");
+end
+function encode(s) return s and (s:gsub("%W", function (c) return string.format("%%%x", c:byte()); end)); end
+function mkdirs(host)
+ if not _mkdir[host] then
+ local host_dir = string.format("%s/%s", data_path, encode(host));
+ mkdir(host_dir);
+ mkdir(host_dir.."/accounts");
+ mkdir(host_dir.."/vcard");
+ mkdir(host_dir.."/roster");
+ mkdir(host_dir.."/private");
+ mkdir(host_dir.."/offline");
+ _mkdir[host] = true;
+ end
+end
+mkdir(data_path);
+
+eventmanager.add_event_hook("host-activated", mkdirs);
+
+----------- End of out-of-place code --------------
+
+eventmanager.fire_event("server-starting");
+
-- Initialise modules
for host in pairs(hosts) do
@@ -159,13 +162,17 @@ if global_ssl_ctx then
end
-- start listening on sockets
-start("xmppclient", { ssl = global_ssl_ctx })
-start("xmppserver", { ssl = global_ssl_ctx })
+cl.start("xmppclient", { ssl = global_ssl_ctx })
+cl.start("xmppserver", { ssl = global_ssl_ctx })
if config.get("*", "core", "console_enabled") then
- start("console")
+ if cl.get("console") then
+ cl.start("console")
+ else
+ log("error", "Console is enabled, but the console module appears not to be loaded");
+ end
end
-modulemanager.fire_event("server-started");
+eventmanager.fire_event("server-started");
server.loop();