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

Commit

Permalink
Fix yellow?
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusAhlfors committed Aug 23, 2023
1 parent f73efe5 commit bd7e37f
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions initialProject/status/status.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,15 @@ const getSupervisorStatus = async (name, process) => {
};

const getWWWStatus = async () => {
const belowYellowThreshold = (new Date().getTime() - timeStart) / 1000 < 30;
try {
const nextjsResponse = (await shellExec('curl http://localhost')).stdout;
if (nextjsResponse && nextjsResponse.includes('__NEXT_DATA__')) {
return {
status: Status.GREEN,
message: '',
};
}

// 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',
};
if (nextjsResponse && nextjsResponse.includes('__NEXT_DATA__')) return { status: Status.GREEN, message: '' };
if (belowYellowThreshold) return { status: Status.YELLOW, message: 'Waiting for Next.js...' };
return { status: Status.RED, message: 'Next.js is not responding' };
} catch {
return {
status: Status.RED,
message: 'Failed to query Next.js status',
};
if (belowYellowThreshold) return { status: Status.YELLOW, message: 'Waiting for Next.js...' };
return { status: Status.RED, message: 'Failed to query Next.js status' };
}
};

Expand Down

0 comments on commit bd7e37f

Please sign in to comment.