diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-06 14:42:18 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-06 14:42:18 +0000 |
commit | 68fa291829af3dc790585d83fbb1dbfa3684cfac (patch) | |
tree | b8137e21c47198f14373e20e5479d05ae4f8bca4 /util | |
parent | 60460d4d2230c785ba392697a1e4cbab6e26ec19 (diff) | |
download | prosody-68fa291829af3dc790585d83fbb1dbfa3684cfac.tar.gz prosody-68fa291829af3dc790585d83fbb1dbfa3684cfac.zip |
util.prosodyctl: Add comments to explain logic and expected behaviour (#1688)
Diffstat (limited to 'util')
-rw-r--r-- | util/prosodyctl.lua | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/util/prosodyctl.lua b/util/prosodyctl.lua index 9cb4b4dd..c6856526 100644 --- a/util/prosodyctl.lua +++ b/util/prosodyctl.lua @@ -40,6 +40,7 @@ local error_messages = setmetatable({ ["unable-to-save-data"] = "Unable to store, perhaps you don't have permission?"; ["no-pidfile"] = "There is no 'pidfile' option in the configuration file, see https://prosody.im/doc/prosodyctl#pidfile for help"; ["invalid-pidfile"] = "The 'pidfile' option in the configuration file is not a string, see https://prosody.im/doc/prosodyctl#pidfile for help"; + ["pidfile-not-locked"] = "Stale pidfile found. Prosody is probably not running."; ["no-posix"] = "The mod_posix module is not enabled in the Prosody config file, see https://prosody.im/doc/prosodyctl for more info"; ["no-such-method"] = "This module has no commands"; ["not-running"] = "Prosody is not running"; @@ -143,8 +144,14 @@ local function getpid() return false, "pidfile-read-failed", err; end + -- Check for a lock on the file local locked, err = lfs.lock(file, "w"); -- luacheck: ignore 211/err if locked then + -- Prosody keeps the pidfile locked while it is running. + -- We successfully locked the file, which means Prosody is not + -- running and the pidfile is stale (somehow it was not + -- cleaned up). We'll abort here, to avoid sending signals to + -- a non-Prosody PID. file:close(); return false, "pidfile-not-locked"; end |