Changeset

10608:87003b937672 0.11

Log warning when using prosodyctl start/stop/restart
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Jan 2020 21:43:36 +0000
parents 10607:a845c877d997
children 10609:f35cbfe546d1 10610:b9a054ad38e7
files prosodyctl
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/prosodyctl	Mon Jan 20 19:51:49 2020 +0100
+++ b/prosodyctl	Thu Jan 23 21:43:36 2020 +0000
@@ -198,11 +198,25 @@
 	return 1;
 end
 
+local function service_command_warning(command)
+	if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then
+		show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended");
+		show_warning("         if Prosody is managed by an init system - use that directly instead.");
+		if lfs.attributes("/etc/systemd") then
+			show_warning("         e.g. systemctl %s prosody", command);
+		elseif lfs.attributes("/etc/init.d/prosody") then
+			show_warning("         e.g. /etc/init.d/prosody %s", command);
+		end
+		show_warning("");
+	end
+end
+
 function commands.start(arg)
 	if arg[1] == "--help" then
 		show_usage([[start]], [[Start Prosody]]);
 		return 1;
 	end
+	service_command_warning("start");
 	local ok, ret = prosodyctl.isrunning();
 	if not ok then
 		show_message(error_messages[ret]);
@@ -293,6 +307,8 @@
 		return 1;
 	end
 
+	service_command_warning("stop");
+
 	if not prosodyctl.isrunning() then
 		show_message("Prosody is not running");
 		return 1;
@@ -328,6 +344,8 @@
 		return 1;
 	end
 
+	service_command_warning("restart");
+
 	commands.stop(arg);
 	return commands.start(arg);
 end
@@ -421,6 +439,8 @@
 		return 1;
 	end
 
+	service_command_warning("reload");
+
 	if not prosodyctl.isrunning() then
 		show_message("Prosody is not running");
 		return 1;