From 0214b44d513d47758ab677bd4a3a2efedb912110 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Tue, 17 Sep 2019 15:30:49 +0200 Subject: [PATCH] :rocket: Add Kubernetes /healthz endpoint --- packages/cli/src/Server.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index f050b5b020..774b9f48ea 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -135,7 +135,7 @@ class App { throw new Error('Basic auth is activated but no password got defined. Please set one!'); } - const authIgnoreRegex = new RegExp(`^\/(rest|${this.endpointWebhook}|${this.endpointWebhookTest})\/.*$`); + const authIgnoreRegex = new RegExp(`^\/(rest|healthz|${this.endpointWebhook}|${this.endpointWebhookTest})\/.*$`); this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { if (req.url.match(authIgnoreRegex)) { return next(); @@ -188,7 +188,7 @@ class App { this.app.use(history({ rewrites: [ { - from: new RegExp(`^\/(rest|css|js|${this.endpointWebhook}|${this.endpointWebhookTest})\/.*$`), + from: new RegExp(`^\/(rest|healthz|css|js|${this.endpointWebhook}|${this.endpointWebhookTest})\/?.*$`), to: (context) => { return context.parsedUrl!.pathname!.toString(); } @@ -219,6 +219,20 @@ class App { + // ---------------------------------------- + // Healthcheck + // ---------------------------------------- + + + // Creates a new workflow + this.app.get('/healthz', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { + return { + status: 'ok', + }; + })); + + + // ---------------------------------------- // Workflow // ----------------------------------------