mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-01-18 18:38:07 +00:00
moved client close out of finally block and fixed linting errors
This commit is contained in:
parent
b059a36e66
commit
2103edb604
1 changed files with 16 additions and 13 deletions
|
@ -301,20 +301,23 @@ exports.postgresQuery = function (connectionString, query) {
|
||||||
* @returns {Promise<(string[]|Object[]|Object)>}
|
* @returns {Promise<(string[]|Object[]|Object)>}
|
||||||
*/
|
*/
|
||||||
exports.mongodbPing = async function (connectionString) {
|
exports.mongodbPing = async function (connectionString) {
|
||||||
let client, db;
|
let client;
|
||||||
try {
|
|
||||||
client = await MongoClient.connect(connectionString, {useNewUrlParser: true})
|
|
||||||
db = client.db();
|
|
||||||
dbping = await db.command({ ping: 1 });
|
|
||||||
if (dbping["ok"] === 1) {
|
|
||||||
return 'UP'
|
|
||||||
}
|
|
||||||
throw Error("failed");
|
|
||||||
}
|
|
||||||
catch(err){ console.error(err); }
|
|
||||||
finally{ client.close(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await MongoClient.connect(connectionString, { useNewUrlParser: true });
|
||||||
|
let db = client.db();
|
||||||
|
let dbping = await db.command({ ping: 1 });
|
||||||
|
await client.close();
|
||||||
|
if (dbping["ok"] === 1) {
|
||||||
|
return "UP";
|
||||||
|
} else {
|
||||||
|
throw Error("failed");
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
throw Error(err)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query radius server
|
* Query radius server
|
||||||
|
|
Loading…
Reference in a new issue