Skip to content

Commit

Permalink
Fix watch db being started on Microservices env
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Dec 2, 2022
1 parent c98c719 commit 159c3cd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/meteor/server/routes/health.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { WebApp } from 'meteor/webapp';

import { isLastDocDelayed } from '../startup/watchDb';
import { isRunningMs } from '../lib/isRunningMs';

WebApp.rawConnectHandlers.use('/health', function (_req, res) {
WebApp.rawConnectHandlers.use('/health', async function (_req, res) {
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
res.setHeader('Pragma', 'no-cache');
res.setHeader('Expires', 0);
res.setHeader('Content-Type', 'text/plain');

if (isLastDocDelayed()) {
res.writeHead(500);
res.end('not healthy');
return;
if (!isRunningMs()) {
const { isLastDocDelayed } = await import('../startup/watchDb');

if (isLastDocDelayed()) {
res.writeHead(500);
res.end('not healthy');
return;
}
}

res.end('ok');
Expand Down

0 comments on commit 159c3cd

Please sign in to comment.