aboutsummaryrefslogtreecommitdiffstats
path: root/util/prosodyctl.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/prosodyctl.lua')
-rw-r--r--util/prosodyctl.lua43
1 files changed, 33 insertions, 10 deletions
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua
index 4d49cd16..9cb4b4dd 100644
--- a/util/prosodyctl.lua
+++ b/util/prosodyctl.lua
@@ -7,17 +7,21 @@
--
-local config = require "core.configmanager";
-local encodings = require "util.encodings";
+local config = require "prosody.core.configmanager";
+local encodings = require "prosody.util.encodings";
local stringprep = encodings.stringprep;
-local storagemanager = require "core.storagemanager";
-local usermanager = require "core.usermanager";
-local interpolation = require "util.interpolation";
-local signal = require "util.signal";
-local set = require "util.set";
+local storagemanager = require "prosody.core.storagemanager";
+local usermanager = require "prosody.core.usermanager";
+local interpolation = require "prosody.util.interpolation";
+local signal = require "prosody.util.signal";
+local set = require "prosody.util.set";
+local path = require"prosody.util.paths";
local lfs = require "lfs";
local type = type;
+local have_socket_unix, socket_unix = pcall(require, "socket.unix");
+have_socket_unix = have_socket_unix and type(socket_unix) == "table"; -- was a function in older LuaSocket
+
local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep;
local io, os = io, os;
@@ -42,7 +46,7 @@ local error_messages = setmetatable({
}, { __index = function (_,k) return "Error: "..(tostring(k):gsub("%-", " "):gsub("^.", string.upper)); end });
-- UI helpers
-local show_message = require "util.human.io".printf;
+local show_message = require "prosody.util.human.io".printf;
local function show_usage(usage, desc)
print("Usage: ".._G.arg[0].." "..usage);
@@ -177,11 +181,31 @@ local function start(source_dir, lua)
if ret then
return false, "already-running";
end
+ local notify_socket;
+ if have_socket_unix then
+ local notify_path = path.join(prosody.paths.data, "notify.sock");
+ os.remove(notify_path);
+ lua = string.format("NOTIFY_SOCKET=%q %s", notify_path, lua);
+ notify_socket = socket_unix.dgram();
+ local ok = notify_socket:setsockname(notify_path);
+ if not ok then return false, "notify-failed"; end
+ end
if not source_dir then
os.execute(lua .. "./prosody -D");
else
os.execute(lua .. source_dir.."/../../bin/prosody -D");
end
+
+ if notify_socket then
+ for i = 1, 5 do
+ notify_socket:settimeout(i);
+ if notify_socket:receivefrom() == "READY=1" then
+ return true;
+ end
+ end
+ return false, "not-ready";
+ end
+
return true;
end
@@ -224,8 +248,7 @@ local function call_luarocks(operation, mod, server)
local ok, _, code = os.execute(render_cli("luarocks --lua-version={luav} {op} --tree={dir} {server&--server={server}} {mod?}", {
dir = dir; op = operation; mod = mod; server = server; luav = _VERSION:match("5%.%d");
}));
- if type(ok) == "number" then code = ok; end
- return code;
+ return ok and code;
end
return {