feat: add logging for health check results and PostgreSQL connection status
This commit is contained in:
@@ -23,6 +23,8 @@ app.get('/health', async (req, res) => {
|
|||||||
|
|
||||||
const allOk = Object.values(postgres).every(s => s === 'connected') && influx && minio;
|
const allOk = Object.values(postgres).every(s => s === 'connected') && influx && minio;
|
||||||
|
|
||||||
|
console.log("Health check results:", { postgres, influx: influx ? 'connected' : 'disconnected', minio: minio ? 'connected' : 'disconnected' });
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
status: allOk ? "ok" : "degraded",
|
status: allOk ? "ok" : "degraded",
|
||||||
service: "api",
|
service: "api",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ async function checkPostgres() {
|
|||||||
for (const [name, pool] of Object.entries(pools)) {
|
for (const [name, pool] of Object.entries(pools)) {
|
||||||
try {
|
try {
|
||||||
await pool.query('SELECT NOW()');
|
await pool.query('SELECT NOW()');
|
||||||
|
console.log(`PostgreSQL connection check successful for ${name}`);
|
||||||
status[name] = 'connected';
|
status[name] = 'connected';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`PostgreSQL connection check failed for ${name}:`, error.message);
|
console.log(`PostgreSQL connection check failed for ${name}:`, error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user