Changeset

2355:08f02de5ab9d

mod_httpserver: Delay setup until after server is started.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 10 Dec 2009 16:21:33 +0500
parents 2354:5a00668ba0ab
children 2356:6d1e745a96f8
files plugins/mod_httpserver.lua
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_httpserver.lua	Thu Dec 10 16:21:06 2009 +0500
+++ b/plugins/mod_httpserver.lua	Thu Dec 10 16:21:33 2009 +0500
@@ -56,6 +56,13 @@
 	return serve_file(path);
 end
 
-local ports = config.get(module.host, "core", "http_ports") or { 5280 };
-httpserver.set_default_handler(handle_default_request);
-httpserver.new_from_config(ports, handle_file_request, { base = "files" });
+local function setup()
+	local ports = config.get(module.host, "core", "http_ports") or { 5280 };
+	httpserver.set_default_handler(handle_default_request);
+	httpserver.new_from_config(ports, handle_file_request, { base = "files" });
+end
+if prosody.start_time then -- already started
+	setup();
+else
+	prosody.events.add_handler("server-started", setup);
+end