I need a lightweight path in my meteor app for health check


#1

So I’m running on Elastic BeanStalk. This was not my decision, but corporate policy due to a need to use our certificates with HTTPS. In any case, that’s the situation.

Elastic BeanStalk runs a “health check” every 10 seconds and it just requests the root path – this ends up being rather expensive, since my app is large and firing it up every 10 seconds is overkill for a health check.

I would like to create a /health route that the app can respond to with a simple 200 OK without downloading the entire app.

Is this possible?

Thanks!


#2

Maybe check out meteorhacks:picker?


#3

I’ve done this in the ProseMeteor project by using the WebApp package directly

import { WebApp } from 'meteor/webapp';

WebApp.rawConnectHandlers.use('/prosemeteor-health-check', (req, res, cb) => {
   res.writeHead(200, {
     'Content-Type': 'text/plain'    
   });
   res.end(HEALTH_CHECK_RESPONSE);
   cb();
 });

//  later on, run health check
let healthCheckRes, healthCheckFailed;
 try {
   healthCheckRes = HTTP.get(healthCheckUrlWithProtocol);
   if (healthCheckRes !== HEALTH_CHECK_RESPONSE) {
     healthCheckFailed = true;
   }
 } catch (e) {
   healthCheckFailed = true;
 }