mod_bosh: Delay setup until after server is started.
authorWaqas Hussain <waqas20@gmail.com>
Thu, 10 Dec 2009 16:21:06 +0500
changeset 2354 5a00668ba0ab
parent 2353 54e650624ded
child 2355 08f02de5ab9d
mod_bosh: Delay setup until after server is started.
plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua	Thu Dec 10 05:08:59 2009 +0500
+++ b/plugins/mod_bosh.lua	Thu Dec 10 16:21:06 2009 +0500
@@ -298,7 +298,14 @@
 	end
 end
 
-local ports = module:get_option("bosh_ports") or { 5280 };
-httpserver.new_from_config(ports, handle_request, { base = "http-bind" });
 
-server.addtimer(on_timer);
+local function setup()
+	local ports = module:get_option("bosh_ports") or { 5280 };
+	httpserver.new_from_config(ports, handle_request, { base = "http-bind" });
+	server.addtimer(on_timer);
+end
+if prosody.start_time then -- already started
+	setup();
+else
+	prosody.events.add_handler("server-started", setup);
+end