prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies...
authorMatthew Wild <mwild1@gmail.com>
Mon, 20 Dec 2010 14:06:16 +0000 (14:06 +0000)
committerMatthew Wild <mwild1@gmail.com>
Mon, 20 Dec 2010 14:06:16 +0000 (14:06 +0000)
prosody
prosodyctl
util/dependencies.lua

diff --git a/prosody b/prosody
index 061f3781ee53904846b623a70999b0f76f18588f..d4bf75781f9ecf39b78bb71a8065b00800e51102 100755 (executable)
--- a/prosody
+++ b/prosody
@@ -35,6 +35,12 @@ end
 prosody = { events = require "util.events".new(); };
 local prosody = prosody;
 
+-- Check dependencies
+local dependencies = require "util.dependencies";
+if not dependencies.check_dependencies() then
+       os.exit(1);
+end
+
 -- Load the config-parsing module
 config = require "core.configmanager"
 
@@ -99,11 +105,8 @@ function init_logging()
        require "core.loggingmanager"
 end
 
-function check_dependencies()
-       -- Check runtime dependencies
-       if not require "util.dependencies".check_dependencies() then
-               os.exit(1);
-       end
+function log_dependency_warnings()
+       dependencies.log_warnings();
 end
 
 function sandbox_require()
@@ -442,13 +445,13 @@ end
 -- previous steps to have already been performed
 read_config();
 init_logging();
-check_dependencies();
 sandbox_require();
 set_function_metatable();
 load_libraries();
 init_global_state();
 read_version();
 log("info", "Hello and welcome to Prosody version %s", prosody.version);
+log_dependency_warnings();
 load_secondary_libraries();
 init_data_store();
 init_global_protection();
index cfc5ca77a979d74268a5483455984ec2da170462..9630a9b8089280e5e7f3f7d79989b3b0b9f7f2a6 100755 (executable)
@@ -41,6 +41,11 @@ prosody = {
 };
 local prosody = prosody;
 
+local dependencies = require "util.dependencies";
+if not dependencies.check_dependencies() then
+       os.exit(1);
+end
+
 config = require "core.configmanager"
 
 do
@@ -94,9 +99,7 @@ config.set("*", "core", "log", { { levels = { min="info" }, to = "console" } });
 
 require "core.loggingmanager"
 
-if not require "util.dependencies".check_dependencies() then
-       os.exit(1);
-end
+dependencies.log_warnings();
 
 local data_path = config.get("*", "core", "data_path") or CFG_DATADIR or "data";
 require "util.datamanager".set_data_path(data_path);
index 6024dd63e6b5154fe7ac7f4cd7914be48da00631..9371521caeca1817320af115c5d2160639b05ec2 100644 (file)
@@ -78,11 +78,6 @@ function check_dependencies()
                                ["luarocks"] = "luarocks install luasec";
                                ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/";
                        }, "SSL/TLS support will not be available");
-       else
-               local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
-               if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
-                       log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
-               end
        end
        
        local encodings, err = softreq "util.encodings"
@@ -121,5 +116,13 @@ function check_dependencies()
        return not fatal;
 end
 
+function log_warnings()
+       if ssl then
+               local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)");
+               if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then
+                       log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends");
+               end
+       end
+end
 
 return _M;