From 0147b972e079bffb40160041de78ec50c5a1bdba Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 30 Jan 2023 00:38:26 +0100 Subject: mod_storage_sql: Record connection to database as module status Allows retrieving this in e.g. a health reporting module Thanks pfak --- plugins/mod_storage_sql.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plugins') 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); -- cgit v1.2.3