Software /
code /
prosody
Diff
plugins/mod_storage_sql.lua @ 12872:a20923f7d5fd
mod_storage_sql: Record connection to database as module status
Allows retrieving this in e.g. a health reporting module
Thanks pfak
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 30 Jan 2023 00:38:26 +0100 |
parent | 12846:1638991caed2 |
child | 12873:7f4f834fae79 |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Mon Jan 30 00:14:50 2023 +0100 +++ b/plugins/mod_storage_sql.lua Mon Jan 30 00:38:26 2023 +0100 @@ -840,6 +840,7 @@ engine = engines[db_uri]; if not engine then module:log("debug", "Creating new engine %s", db_uri); + module:log_status("debug", "Creating new engine for "..params.driver); engine = sql:create_engine(params, function (engine) -- luacheck: ignore 431/engine if module:get_option("sql_manage_tables", true) then -- Automatically create table, ignore failure (table probably already exists) @@ -858,8 +859,13 @@ end end end + module:set_status("info", "Connected to " .. engine.params.driver); + end, function (engine) + module:set_status("error", "Disconnected from " .. engine.params.driver); end); engines[sql.db2uri(params)] = engine; + else + module:set_status("info", "Using existing engine"); end module:provides("storage", driver);