changeset 320:8d4f3cd41f82

mod_post_msg: Better initialization
author Kim Alvefur <zash@zash.se>
date Thu, 27 Jan 2011 17:30:48 +0100
parents ba2e78661ea8
children 661f64627fed
files mod_post_msg/mod_post_msg.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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