aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-01-30 00:38:26 +0100
committerKim Alvefur <zash@zash.se>2023-01-30 00:38:26 +0100
commit0147b972e079bffb40160041de78ec50c5a1bdba (patch)
tree5ef5ca70fd4f51dcfc2ec6c2036868bca8d714e4 /plugins
parentdc958f1e40eef23f6aed6eba17c30f3b880b3c08 (diff)
downloadprosody-0147b972e079bffb40160041de78ec50c5a1bdba.tar.gz
prosody-0147b972e079bffb40160041de78ec50c5a1bdba.zip
mod_storage_sql: Record connection to database as module status
Allows retrieving this in e.g. a health reporting module Thanks pfak
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index 45fda70d..824bcf14 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -840,6 +840,7 @@ function module.load()
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 @@ function module.load()
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);