Changeset

9215:b087b5047f86

net.server: Throw error when loading outside Prosody or Prosody config not loaded
author Matthew Wild <mwild1@gmail.com>
date Sun, 19 Aug 2018 14:45:19 +0100
parents 9214:8b2b8f1a911f
children 9216:ba38a947020e
files net/server.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/server.lua	Sun Aug 19 14:44:50 2018 +0100
+++ b/net/server.lua	Sun Aug 19 14:45:19 2018 +0100
@@ -6,9 +6,16 @@
 -- COPYING file in the source package for more information.
 --
 
+if not (prosody and prosody.config_loaded) then
+	-- This module only supports loading inside Prosody, outside Prosody
+	-- you should directly require net.server_select or server_event, etc.
+	error(debug.traceback("Loading outside Prosody or Prosody not yet initialized"), 0);
+end
+
 local log = require "util.logger".init("net.server");
-local server_type = prosody and require "core.configmanager".get("*", "network_backend") or "select";
-if prosody and require "core.configmanager".get("*", "use_libevent") then
+local server_type = require "core.configmanager".get("*", "network_backend") or "select";
+
+if require "core.configmanager".get("*", "use_libevent") then
 	server_type = "event";
 end