mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-18 04:04:41 -05:00
Fixed MySQL monitor to close connection
Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
f9be918246
commit
b053bc61ce
@ -13,7 +13,7 @@ const { badgeConstants } = require("./config");
|
|||||||
const mssql = require("mssql");
|
const mssql = require("mssql");
|
||||||
const { Client } = require("pg");
|
const { Client } = require("pg");
|
||||||
const postgresConParse = require("pg-connection-string").parse;
|
const postgresConParse = require("pg-connection-string").parse;
|
||||||
const mysql = require("mysql2/promise");
|
const mysql = require("mysql2");
|
||||||
const { NtlmClient } = require("axios-ntlm");
|
const { NtlmClient } = require("axios-ntlm");
|
||||||
const { Settings } = require("./settings");
|
const { Settings } = require("./settings");
|
||||||
const radiusClient = require("node-radius-client");
|
const radiusClient = require("node-radius-client");
|
||||||
@ -300,16 +300,16 @@ exports.postgresQuery = function (connectionString, query) {
|
|||||||
*/
|
*/
|
||||||
exports.mysqlQuery = function (connectionString, query) {
|
exports.mysqlQuery = function (connectionString, query) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return mysql.createConnection(connectionString)
|
const connection = mysql.createConnection(connectionString);
|
||||||
.then(connection => {
|
connection.promise().query(query)
|
||||||
connection.connect();
|
|
||||||
return connection.query(query);
|
|
||||||
})
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
resolve(res);
|
resolve(res);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
connection.end();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user