chore: Add /_health endpoint to all services

closes #2506
This commit is contained in:
Tom Moor
2021-08-29 19:44:06 -07:00
parent 2024c6e64f
commit 08a8fea69a
2 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import Koa from "koa";
import compress from "koa-compress";
import helmet from "koa-helmet";
import logger from "koa-logger";
import Router from "koa-router";
import { uniq } from "lodash";
import stoppable from "stoppable";
import throng from "throng";
@ -40,7 +41,9 @@ async function start(id, disconnect) {
const server = stoppable(http.createServer(app.callback()));
const httpLogger = debug("http");
const log = debug("server");
const router = new Router();
// install basic middleware shared by all services
app.use(logger((str, args) => httpLogger(str)));
app.use(compress());
app.use(helmet());
@ -56,6 +59,10 @@ async function start(id, disconnect) {
await init(app, server);
}
// install health check endpoint for all services
router.get("/_health", (ctx) => (ctx.body = "OK"));
app.use(router.routes());
server.on("error", (err) => {
throw err;
});

View File

@ -93,8 +93,6 @@ koa.use(
})
);
router.get("/_health", (ctx) => (ctx.body = "OK"));
if (process.env.NODE_ENV === "production") {
router.get("/static/*", async (ctx) => {
ctx.set({