Mercurial > prosody-hg
changeset 13979:2041c347c178 13.0
util.startup: Inform process manager about failure to reload config
Ref https://www.freedesktop.org/software/systemd/man/249/sd_notify.html
> Note that a service that sends this notification must also send a
> "READY=1" notification when it completed reloading its configuration.
However no word on how to handle errors while doing that, such as
configuration syntax errors, but communicating this via STATUS= makes
some sense.
Fixes #1970
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 06 Oct 2025 01:22:40 +0200 |
| parents | 9974b210d620 |
| children | d8c001271669 837d47c24e3f |
| files | util/startup.lua |
| diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/startup.lua Thu Oct 02 21:09:29 2025 +0200 +++ b/util/startup.lua Mon Oct 06 01:22:40 2025 +0200 @@ -347,6 +347,10 @@ elseif level == "file" then log("error", "Couldn't read the config file when trying to reload: %s", err); end + prosody.events.fire_event("config-reload-failed", { + filename = prosody.config_file; + level = level; error = err; + }); else prosody.events.fire_event("config-reloaded", { filename = prosody.config_file, @@ -859,6 +863,15 @@ prosody.events.add_handler("reloading-config", function() notify_socket:send(string.format("RELOADING=1\nMONOTONIC_USEC=%d", math.floor(time.monotonic() * 1000000))); end); + prosody.events.add_handler("config-reload-failed", function(event) + if event and event.level == "parser" then + notify_socket:send(string.format("READY=1\nSTATUS=Error parsing configuration file: %s", tostring(event.error))); + elseif event and event.level == "file" then + notify_socket:send(string.format("READY=1\nSTATUS=Could not read configuration file: %s", tostring(event.error))); + else + notify_socket:send("READY=1\nSTATUS=Could not read configuration file"); + end + end); prosody.events.add_handler("config-reloaded", function() notify_socket:send("READY=1"); end);
