Skip to content
Snippets Groups Projects
Unverified Commit 3eed4a7b authored by Diego Sampaio's avatar Diego Sampaio Committed by GitHub
Browse files

chore: improve health check log messages (#29787)

parent 45a8943e
No related branches found
No related tags found
No related merge requests found
import { WebApp } from 'meteor/webapp';
import { isRunningMs } from '../lib/isRunningMs';
import { SystemLogger } from '../lib/logger/system';
WebApp.rawConnectHandlers.use('/health', async function (_req, res) {
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
......@@ -12,6 +13,7 @@ WebApp.rawConnectHandlers.use('/health', async function (_req, res) {
const { isLastDocDelayed } = await import('../startup/watchDb');
if (isLastDocDelayed()) {
SystemLogger.error('System not healthy due to no real time data received recently');
res.writeHead(500);
res.end('not healthy');
return;
......
......@@ -153,7 +153,11 @@ export class DDPStreamer extends ServiceClass {
.use(proxy())
.get('/health', async (_req, res) => {
try {
await this.api?.nodeList();
if (!this.api) {
throw new Error('API not available');
}
await this.api.nodeList();
res.end('ok');
} catch (err) {
console.error('Service not healthy', err);
......
......@@ -33,7 +33,7 @@ const PORT = process.env.PORT || 3035;
await api.nodeList();
if (watcher.isLastDocDelayed()) {
throw new Error('not healthy');
throw new Error('No real time data received recently');
}
} catch (err) {
console.error('Service not healthy', err);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment