aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2024-03-27 19:33:11 +0100
committerKim Alvefur <zash@zash.se>2024-03-27 19:33:11 +0100
commite311f13c4342a2dfc059fd15fe87e51375b95398 (patch)
treed75c4ecb47d0f9952b24c602e77c510f058f1c76 /util
parenta8556c18757df09419d82f8fc5f5bbf27769e1a3 (diff)
downloadprosody-e311f13c4342a2dfc059fd15fe87e51375b95398.tar.gz
prosody-e311f13c4342a2dfc059fd15fe87e51375b95398.zip
util.startup: Fix exiting on pidfile trouble
prosody.shutdown() relies on prosody.main_thread, which has not been set yet at this point. Doing a clean shutdown might actually be harmful in case it tears down things set up by the conflicting Prosody, such as the very pidfile we were looking at. Thanks again SigmaTel71 for noticing
Diffstat (limited to 'util')
-rw-r--r--util/startup.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/util/startup.lua b/util/startup.lua
index 7f0c4354..60fd6339 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -719,20 +719,20 @@ function startup.write_pidfile()
local pidfile_handle, err = io.open(pidfile, mode);
if not pidfile_handle then
log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
- prosody.shutdown("Couldn't write pidfile", 1);
+ os.exit(1);
else
prosody.pidfile = pidfile;
if not lfs.lock(pidfile_handle, "w") then -- Exclusive lock
local other_pid = pidfile_handle:read("*a");
log("error", "Another Prosody instance seems to be running with PID %s, quitting", other_pid);
prosody.pidfile_handle = nil;
- prosody.shutdown("Prosody already running", 1);
+ os.exit(1);
else
pidfile_handle:close();
pidfile_handle, err = io.open(pidfile, "w+");
if not pidfile_handle then
log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
- prosody.shutdown("Couldn't write pidfile", 1);
+ os.exit(1);
else
if lfs.lock(pidfile_handle, "w") then
pidfile_handle:write(tostring(pposix.getpid()));