Skip to content

Commit

Permalink
DO-1666: add dedicated healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gowrizrh committed Jun 3, 2024
1 parent 8da8cb3 commit c7094e5
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions packages/prerender-fargate/lib/prerender/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,31 @@ const server = prerender({
chromeLocation: '/usr/bin/chromium-browser'
});

// Healthcheck endpoint
server.use({
beforeSend: (req, res, next) => {
if (req.prerender.url === "health") {
return res.send(200, 'OK');
}

return next();
}
});

server.use({
beforeSend: (req, res, next) => {
const ms = new Date().getTime() - req.prerender.start.getTime();

if (req.prerender.url !== "health") {
logger.render({
time: ms,
path: req.prerender.url,
status: req.prerender.statusCode,
ip: req.socket.remoteAddress,
headers: req.prerender.headers,
origin: req.headers
});
}
logger.render({
time: ms,
path: req.prerender.url,
status: req.prerender.statusCode,
ip: req.socket.remoteAddress,
headers: req.prerender.headers,
origin: req.headers
});

next();
return next();
},
});

Expand Down

0 comments on commit c7094e5

Please sign in to comment.