mod_audit_status: Expose 'crashed' flag
authorMatthew Wild <mwild1@gmail.com>
Tue, 20 Feb 2024 17:11:42 +0000
changeset 5844 bd0abf821cef
parent 5843 fba64b043c52
child 5845 904b226fddf1
mod_audit_status: Expose 'crashed' flag
mod_audit_status/mod_audit_status.lua
--- a/mod_audit_status/mod_audit_status.lua	Thu Feb 15 09:20:50 2024 -0800
+++ b/mod_audit_status/mod_audit_status.lua	Tue Feb 20 17:11:42 2024 +0000
@@ -9,10 +9,14 @@
 
 local store = module:open_store(nil, "keyval+");
 
+-- This is global, to make it available to other modules
+crashed = false; --luacheck: ignore 131/crashed
+
 module:hook_global("server-started", function ()
 	local recorded_status = store:get();
 	if recorded_status and recorded_status.status == "started" then
 		module:audit(nil, "server-crashed", { timestamp = recorded_status.heartbeat });
+		crashed = true;
 	end
 	module:audit(nil, "server-started");
 	store:set_key(nil, "status", "started");