Software /
code /
prosody-modules
File
mod_audit_status/mod_audit_status.lua @ 5344:0a6d2b79a8bf
mod_auth_oauth_external: Authenticate against an OAuth 2 provider
But suddenly unsure whether this constitutes an OAuth "client" or
something else? Resource server maybe?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 16 Mar 2023 12:45:22 +0100 |
parent | 5324:18fd615c2733 |
child | 5353:14b6397cd6de |
line wrap: on
line source
module:depends("audit"); local st = require "util.stanza"; -- Suppress warnings about module:audit() -- luacheck: ignore 143/module local heartbeat_interval = module:get_option_number("audit_status_heartbeat_interval", 60); local store = module:open_store(nil, "keyval+"); module:hook_global("server-started", function () local recorded_status = store:get(); if recorded_status.status == "started" then module:audit(nil, "server-crashed", { timestamp = recorded_status.heartbeat }); end module:audit(nil, "server-started"); store:set_key(nil, "status", "started"); end); module:hook_global("server-stopped", function () module:audit(nil, "server-stopped", { custom = { prosody.shutdown_reason and st.stanza("note"):text(prosody.shutdown_reason); }; }); store:set_key(nil, "status", "stopped"); end); if heartbeat_interval then module:add_timer(0, function () store:set_key(nil, "heartbeat", os.time()); return heartbeat_interval; end); end