Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Status: Show yellow for Next.js at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusAhlfors committed Aug 23, 2023
1 parent f9c5e14 commit f73efe5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions initialProject/status/status.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import http from 'http';
import { shellExec } from './shellExec.mjs';

const timeStart = new Date().getTime();

const Status = {
GREEN: 'green',
YELLOW: 'yellow',
Expand Down Expand Up @@ -53,6 +55,14 @@ const getWWWStatus = async () => {
};
}

// Give Next.js some time before returning error
if ((new Date().getTime() - timeStart) / 1000 < 30) {
return {
status: Status.YELLOW,
message: 'Waiting for Next.js...',
};
}

return {
status: Status.RED,
message: 'Next.js is not responding',
Expand Down

0 comments on commit f73efe5

Please sign in to comment.