diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-06 14:51:31 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-06 14:51:31 +0000 |
commit | 0a93dccaa9fe20ace9e648eeac9cc155c3f668e9 (patch) | |
tree | e68435d409d763ded80bbebee69759cadbe072b8 /prosodyctl | |
parent | 08d69fb759a10ad43158df4908773c3879579189 (diff) | |
download | prosody-0a93dccaa9fe20ace9e648eeac9cc155c3f668e9.tar.gz prosody-0a93dccaa9fe20ace9e648eeac9cc155c3f668e9.zip |
prosodyctl: Further deprecate start/stop/restart commands when installed
Despite the warning we introduced, many people continue to try using
prosodyctl to manage Prosody in the presence of systemctl (e.g. #1688).
Also, despite the warning, prosodyctl proceeded with the operation. This means
the commands could be invoked by accident, and cause a situation that is hard
to recover from (needing to manually track down stray processes).
This commit disables all the problematic commands by default, but this can
still be overridden using --force or via a config option.
We only perform this check when we believe Prosody has been "installed" for
system-wide use (i.e. running it from a source directory is still supported).
Diffstat (limited to 'prosodyctl')
-rwxr-xr-x | prosodyctl | 46 |
1 files changed, 35 insertions, 11 deletions
@@ -181,16 +181,30 @@ local function has_init_system() --> which end local function service_command_warning(service_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 true or prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then + show_warning("ERROR: Use of 'prosodyctl %s' is disabled in this installation because", service_command); + local init = has_init_system() - if init == "systemd" then - show_warning(" e.g. systemctl %s prosody", service_command); - elseif init == "rc.d" then - show_warning(" e.g. /etc/init.d/prosody %s", service_command); + if init then + show_warning(" we detected that this system uses %s for managing services.", init); + show_warning(""); + show_warning(" To avoid problems, use that directly instead. For example:"); + show_warning(""); + if init == "systemd" then + show_warning(" systemctl %s prosody", service_command); + elseif init == "rc.d" then + show_warning(" /etc/init.d/prosody %s", service_command); + end + else + show_warning(" it may conflict with your system's service manager."); + show_warning(""); end - show_warning(""); + + show_warning(" Proceeding to use prosodyctl may cause process management issues."); + show_warning(" You can pass --force to override this warning, or set"); + show_warning(" prosodyctl_service_warnings = false in your global config."); + + os.exit(1); end end @@ -200,7 +214,9 @@ function commands.start(arg) show_usage([[start]], [[Start Prosody]]); return 0; end - service_command_warning("start"); + if not opts.force then + service_command_warning("start"); + end local ok, ret = prosodyctl.isrunning(); if not ok then show_message(error_messages[ret]); @@ -301,7 +317,9 @@ function commands.stop(arg) return 0; end - service_command_warning("stop"); + if not opts.force then + service_command_warning("stop"); + end local ok, running = prosodyctl.isrunning(); if not ok then @@ -343,7 +361,9 @@ function commands.restart(arg) return 1; end - service_command_warning("restart"); + if not opts.force then + service_command_warning("restart"); + end commands.stop(arg); return commands.start(arg); @@ -530,6 +550,10 @@ function commands.reload(arg) return 1; end + if not opts.force then + service_command_warning("reload"); + end + local ok, ret = prosodyctl.reload(); if ok then |