Skip to content

Commit

Permalink
chore(plugin-server): add healthcheck logging for failure (#14455)
Browse files Browse the repository at this point in the history
Previously it was just always logging OK even if it wasn't
  • Loading branch information
Harry Waye authored Feb 28, 2023
1 parent 76b7480 commit 63cf096
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin-server/src/main/services/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function createHttpServer(
): Server {
const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
if (req.url === '/_health' && req.method === 'GET') {
status.info('💚', 'Server liveness check succeeded')
// Check that all health checks pass. Note that a failure of these
// _may_ result in the process being terminated by e.g. Kubernetes
// so the stakes are high.
Expand Down Expand Up @@ -60,6 +59,13 @@ export function createHttpServer(
)

res.statusCode = statusCode

if (statusCode === 200) {
status.info('💚', 'Server liveness check succeeded')
} else {
status.info('💔', 'Server liveness check failed', checkResults)
}

res.end(JSON.stringify({ status: statusCode === 200 ? 'ok' : 'error', checks: checkResultsMapping }))
} else if (req.url === '/_ready' && req.method === 'GET') {
// Check that, if the server should have a kafka queue,
Expand Down

0 comments on commit 63cf096

Please sign in to comment.