Skip to content

Commit

Permalink
add healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Oct 6, 2024
1 parent 1606678 commit 779f843
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ RUN npm install
COPY . .
RUN npm run build
RUN npm prune --prod
HEALTHCHECK CMD ["wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/up", "||", "exit", "1"]
CMD ["npm", "start"]
4 changes: 3 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ await app.register(fastifyCors, {
});

app.addHook("onRequest", async (request, reply) => {
if (request.method === "OPTIONS") {
if (request.method === "OPTIONS" || request.url === "/up") {
return;
}
try {
Expand Down Expand Up @@ -223,6 +223,8 @@ app.get("/searches/missed/rank", async (request, reply) => {
return reply.status(200).send({ data: await getMissedSearchRank(dates, limit), success: true });
});

app.get("/up", async(request, reply) => reply.status(204));

await app.listen({
host: "0.0.0.0",
port: 3000
Expand Down

0 comments on commit 779f843

Please sign in to comment.