From 4c0bc186ae651bd1815d6e7e7c0b9eb601763601 Mon Sep 17 00:00:00 2001 From: Bruno Saboia de Albuquerque Date: Thu, 10 Mar 2022 03:38:13 +0100 Subject: [PATCH] Add /healthz endpoint There is still work to be done here. Ideally, this endpoint should return information about the document store health, and return a more informative 200 instead of an empty 204. Fixes #383 --- Dockerfile | 2 +- server.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5e241ab..5898699 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ ENTRYPOINT [ "bash", "docker-entrypoint.sh" ] HEALTHCHECK --interval=30s --timeout=30s --start-period=5s \ --retries=3 CMD [ "sh", "-c", "echo -n 'curl localhost:7777... '; \ (\ - curl -sf localhost:7777 > /dev/null\ + curl -sf localhost:7777/healthz > /dev/null\ ) && echo OK || (\ echo Fail && exit 2\ )"] diff --git a/server.js b/server.js index 0837a03..d2b4fc5 100644 --- a/server.js +++ b/server.js @@ -109,6 +109,11 @@ if (config.rateLimits) { // first look at API calls app.use(route(function(router) { + // get healthz + router.get("/healthz", function (request, response) { + response.writeHead(204); + response.end(); + }); // get raw documents - support getting with extension router.get('/raw/:id', function(request, response) {