Skip to content

Commit

Permalink
Add healthcheck to gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
yhtMinceraft1010X authored Oct 27, 2023
1 parent fe4dc1d commit 1c28242
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deployment/gke-prod-manifests/gateway-backend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ spec:
healthCheck:
timeoutSec: 3
type: HTTP
requestPath: /healthz
port: 8080
requestPath: /healthcheck
port: 4000
customResponseHeaders:
headers:
- "Access-Control-Allow-Origin: https://www.codeparty.org"
Expand Down
2 changes: 2 additions & 0 deletions services/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express-healthcheck": "^0.1.0",
"firebase-admin": "^11.10.1",
"http-proxy-middleware": "^2.0.6",
"morgan": "^1.10.0"
},
"devDependencies": {
"@types/cors": "^2.8.14",
"@types/express-healthcheck": "^0.1.2",
"@types/morgan": "^1.9.6",
"swagger-autogen": "^2.23.6",
"ts-node-dev": "^2.0.0",
Expand Down
4 changes: 4 additions & 0 deletions services/gateway/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { setupProxies } from "./proxy/proxy";
import {http_proxied_routes, wsCollaborationProxiedRoutes, wsMatchProxiedRoutes} from "./proxied_routes/proxied_routes";
import {frontendAddress} from "./proxied_routes/service_names";
import {createProxyMiddleware} from "http-proxy-middleware";
import healthCheck from "express-healthcheck";


const httpApp : Express = express();
Expand All @@ -25,6 +26,9 @@ httpApp.use(cors(corsOptions));
wsMatchApp.use(cors(corsOptions));
wsCollaborationApp.use(cors(corsOptions));

// Health check
httpApp.use('/healthcheck', healthCheck());

/**
* WARNING: Do not add body parsing middleware to the Gateway.
* Otherwise, proxying POST requests with request body would not work.
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,13 @@
dependencies:
"@types/node" "*"

"@types/express-healthcheck@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/express-healthcheck/-/express-healthcheck-0.1.2.tgz#1f1aa8846d5e0fb9f71a9acad8ac2f1806bf6fd6"
integrity sha512-enSA1JuIErGJqfCCDmNAq6N8OIBhgdg+mBvHUOTrjy7zdrDEKJ4sJr97MoFZNIDh32bUII1F+uPmqgC9H8b4mQ==
dependencies:
"@types/express" "*"

"@types/express-serve-static-core@^4.17.33":
version "4.17.39"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.39.tgz#2107afc0a4b035e6cb00accac3bdf2d76ae408c8"
Expand Down Expand Up @@ -6050,6 +6057,11 @@ exponential-backoff@^3.1.1:
resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.1.tgz#64ac7526fe341ab18a39016cd22c787d01e00bf6"
integrity sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==

express-healthcheck@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/express-healthcheck/-/express-healthcheck-0.1.0.tgz#cabec78129c4cb90cd7fb894dfae21b82e27cb07"
integrity sha512-FKQVgDo1FMSOYflEq4g6CvNk6stbpkuX0MWXmul8dSICuw/b+3JgoYOq/aiDcYid5k42jh/4HYLYC/M/qDBEuQ==

express-normalize-query-params-middleware@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/express-normalize-query-params-middleware/-/express-normalize-query-params-middleware-0.5.1.tgz#dbe1e8139aecb234fb6adb5c0059c75db9733d2a"
Expand Down

0 comments on commit 1c28242

Please sign in to comment.