mod_bosh: Delay setup until after server is started.
authorWaqas Hussain <waqas20@gmail.com>
Thu, 10 Dec 2009 11:21:06 +0000 (16:21 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Thu, 10 Dec 2009 11:21:06 +0000 (16:21 +0500)
plugins/mod_bosh.lua

index 5de79eff187c4580ab88a5322a30991102b3a57c..db70006c560203cf856f82088bd660f611d0f354 100644 (file)
@@ -298,7 +298,14 @@ function on_timer()
        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