Permalink
Browse files

Add a GET /status 200

Add a healthcheck in docker conf
  • Loading branch information...
canssens committed Sep 21, 2018
1 parent cba10a6 commit 42d27e96d7b9c3e2544e533ce527b45154ef70ab
Showing with 21 additions and 7 deletions.
  1. +4 −0 Dockerfile
  2. +17 −7 index.js
@@ -8,4 +8,8 @@ ENV TILE_SET_CACHE 128
ENV TILE_SET_PATH /app/data
ENV MAX_POST_SIZE 700kb

EXPOSE 3000

HEALTHCHECK CMD curl --fail http://localhost:3000/status || exit 1

CMD ["yarn", "run", "start"]
@@ -53,13 +53,23 @@ async function handleGET(req, res) {
return result;
}

async function handleGETStatus(req, res) {
return send(res, 200);
}

module.exports = async (req, res) => {
switch (req.method) {
case "POST":
return handlePOST(req, res);
case "GET":
return handleGET(req, res);
default:
return send(res, 405, { error: "Only GET or POST allowed" });
if (req.method == "GET" && req.url == "/status") {
return handleGETStatus(req, res);
}
else
{
switch (req.method) {
case "POST":
return handlePOST(req, res);
case "GET":
return handleGET(req, res);
default:
return send(res, 405, { error: "Only GET or POST allowed" });
}
}
};

0 comments on commit 42d27e9

Please sign in to comment.