diff options
author | Kim Alvefur <zash@zash.se> | 2023-01-30 00:38:26 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-01-30 00:38:26 +0100 |
commit | 0147b972e079bffb40160041de78ec50c5a1bdba (patch) | |
tree | 5ef5ca70fd4f51dcfc2ec6c2036868bca8d714e4 /plugins | |
parent | dc958f1e40eef23f6aed6eba17c30f3b880b3c08 (diff) | |
download | prosody-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.lua | 6 |
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); |