X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=prosody;h=aab803c5b8c71c16ce616a7b0ccb09ef617f4318;hb=6fa9af28f8aec06efc8f7ee4d1e9598575fb48a2;hp=1a0f6ff2d76119f7907785187a94e0541be72079;hpb=313b61ae6320a330096992127a9658f959bcd977;p=prosody.git diff --git a/prosody b/prosody index 1a0f6ff2..aab803c5 100755 --- a/prosody +++ b/prosody @@ -49,9 +49,6 @@ _G.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" @@ -86,6 +83,7 @@ function read_config() break; end end + prosody.config_file = filename local ok, level, err = config.load(filename); if not ok then print("\n"); @@ -115,6 +113,12 @@ function read_config() end end +function check_dependencies() + if not dependencies.check_dependencies() then + os.exit(1); + end +end + function load_libraries() -- Load socket framework server = require "net.server" @@ -149,7 +153,12 @@ function sandbox_require() local _real_require = require; if not getfenv then -- FIXME: This is a hack to replace getfenv() in Lua 5.2 - function getfenv(f) return debug.getupvalue(debug.getinfo(f or 1).func, 1); end + function getfenv(f) + local name, env = debug.getupvalue(debug.getinfo(f or 1).func, 1); + if name == "_ENV" then + return env; + end + end end function require(...) local curr_env = getfenv(2); @@ -240,7 +249,7 @@ function init_global_state() function prosody.reload_config() log("info", "Reloading configuration file"); prosody.events.fire_event("reloading-config"); - local ok, level, err = config.load((rawget(_G, "CFG_CONFIGDIR") or ".").."/prosody.cfg.lua"); + local ok, level, err = config.load(prosody.config_file); if not ok then if level == "parser" then log("error", "There was an error parsing the configuration file: %s", tostring(err)); @@ -381,6 +390,7 @@ init_logging(); sanity_check(); sandbox_require(); set_function_metatable(); +check_dependencies(); load_libraries(); init_global_state(); read_version();