From 1212e6b266665cf6d8523687ca4cba10c6869233 Mon Sep 17 00:00:00 2001 From: giacung Date: Fri, 2 Oct 2015 13:46:03 +0200 Subject: [PATCH] Health check should verify that it can talk to the toggle-store (aka DB). This commit fixes #103 by doing a simple select against the features table. --- lib/routes.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/routes.js b/lib/routes.js index a7d89154a7..66206416dd 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -1,7 +1,18 @@ +var knex = require('./dbPool'); +var logger = require('./logger'); + module.exports = function (app) { app.get('/health', function (req, res) { - res.json({health: 'GOOD'}); + knex.select(1) + .from('features') + .then(function() { + res.json({health: 'GOOD'}); + }) + .catch(function(err) { + logger.error('Could not select from features, error was: ', err); + res.status(500).json({health: 'BAD'}); + }); }); -}; \ No newline at end of file +};