mod_post_msg: Better initialization
authorKim Alvefur <zash@zash.se>
Thu, 27 Jan 2011 17:30:48 +0100
changeset 320 8d4f3cd41f82
parent 319 ba2e78661ea8
child 321 661f64627fed
mod_post_msg: Better initialization
mod_post_msg/mod_post_msg.lua
--- a/mod_post_msg/mod_post_msg.lua	Fri Jan 21 04:10:40 2011 +0100
+++ b/mod_post_msg/mod_post_msg.lua	Thu Jan 27 17:30:48 2011 +0100
@@ -105,5 +105,12 @@
 	return http_response(202, "Accepted")
 end
 
-local ports = config.get(module.host, "core", "post_msg_ports") or { 5280 };
-require "net.httpserver".new_from_config(ports, "msg", handle_request);
+local function setup()
+	local ports = module:get_option("post_msg_ports") or { 5280 };
+	require "net.httpserver".new_from_config(ports, handle_request, { base = "msg" });
+end
+if prosody.start_time then -- already started
+	setup();
+else
+	prosody.events.add_handler("server-started", setup);
+end