Comparison

mod_audit_status/mod_audit_status.lua @ 5324:18fd615c2733

mod_audit_status: Include shutdown reason in log entry
author Matthew Wild <mwild1@gmail.com>
date Fri, 07 Apr 2023 13:10:43 +0100
parent 5320:c450dbf6c0fa
child 5353:14b6397cd6de
comparison
equal deleted inserted replaced
5323:400ffa842576 5324:18fd615c2733
1 module:depends("audit"); 1 module:depends("audit");
2
3 local st = require "util.stanza";
2 4
3 -- Suppress warnings about module:audit() 5 -- Suppress warnings about module:audit()
4 -- luacheck: ignore 143/module 6 -- luacheck: ignore 143/module
5 7
6 local heartbeat_interval = module:get_option_number("audit_status_heartbeat_interval", 60); 8 local heartbeat_interval = module:get_option_number("audit_status_heartbeat_interval", 60);
15 module:audit(nil, "server-started"); 17 module:audit(nil, "server-started");
16 store:set_key(nil, "status", "started"); 18 store:set_key(nil, "status", "started");
17 end); 19 end);
18 20
19 module:hook_global("server-stopped", function () 21 module:hook_global("server-stopped", function ()
20 module:audit(nil, "server-stopped"); 22 module:audit(nil, "server-stopped", {
23 custom = {
24 prosody.shutdown_reason and st.stanza("note"):text(prosody.shutdown_reason);
25 };
26 });
21 store:set_key(nil, "status", "stopped"); 27 store:set_key(nil, "status", "stopped");
22 end); 28 end);
23 29
24 if heartbeat_interval then 30 if heartbeat_interval then
25 module:add_timer(0, function () 31 module:add_timer(0, function ()