feat: implement comprehensive health check endpoints for API, Auth, and Realtime services to monitor database, Redis, MinIO, and InfluxDB connectivity.
This commit is contained in:
@@ -59,9 +59,19 @@ async function query(bucket, relativeTime, measurement, sensor, field) {
|
||||
|
||||
}
|
||||
|
||||
async function checkInflux() {
|
||||
try {
|
||||
await querying.rows(`from(bucket: "boat") |> range(start: -1s) |> limit(n:1)`).next();
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
write:append,
|
||||
writeBatch,
|
||||
query
|
||||
query,
|
||||
checkInflux
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,15 @@ async function getFileStream(bucket, objectName) {
|
||||
return dataStream;
|
||||
}
|
||||
|
||||
async function checkMinio() {
|
||||
try {
|
||||
await client.listBuckets();
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bucketExists,
|
||||
getBuckets,
|
||||
@@ -132,5 +141,6 @@ module.exports = {
|
||||
removeObject,
|
||||
upload,
|
||||
download,
|
||||
getFileStream
|
||||
getFileStream,
|
||||
checkMinio
|
||||
}
|
||||
@@ -70,10 +70,24 @@ async function remove(table, condition, params, type = 'users') {
|
||||
const sql = `DELETE FROM ${table} WHERE ${condition}`;
|
||||
return await query(sql, params, type);
|
||||
}
|
||||
|
||||
async function checkPostgres() {
|
||||
const status = {};
|
||||
for (const [name, pool] of Object.entries(pools)) {
|
||||
try {
|
||||
await pool.query('SELECT NOW()');
|
||||
status[name] = 'connected';
|
||||
} catch (error) {
|
||||
status[name] = 'disconnected';
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
module.exports = {
|
||||
query,
|
||||
append,
|
||||
remove,
|
||||
getClient,
|
||||
checkPostgres,
|
||||
pools
|
||||
};
|
||||
Reference in New Issue
Block a user