Skip to content

Commit

Permalink
Add a GET /status 200
Browse files Browse the repository at this point in the history
Add a healthcheck in docker conf
  • Loading branch information
canssens committed Sep 21, 2018
1 parent cba10a6 commit 42d27e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
24 changes: 17 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.