Skip to content

Commit 68bfa75

Browse files
authored
Merge pull request #12994 from github/repo-sync
repo sync
2 parents 9ca0226 + b6e6523 commit 68bfa75

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

middleware/healthz.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import express from 'express'
2+
3+
const router = express.Router()
4+
5+
/**
6+
* Returns the healthiness of the service.
7+
* This may be used by azure app service (forthcoming) to determine whether this
8+
* instance remains in the pool to handle requests
9+
* For example: if we have a failing database connection we may return a 500 status here.
10+
*/
11+
router.get('/', function healthz(req, res, next) {
12+
res.set({
13+
'surrogate-control': 'private, no-store',
14+
'cache-control': 'private, no-store',
15+
})
16+
17+
res.sendStatus(200)
18+
})
19+
20+
export default router

middleware/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import blockRobots from './block-robots.js'
3838
import archivedEnterpriseVersionsAssets from './archived-enterprise-versions-assets.js'
3939
import events from './events.js'
4040
import search from './search.js'
41+
import healthz from './healthz.js'
4142
import archivedEnterpriseVersions from './archived-enterprise-versions.js'
4243
import robots from './robots.js'
4344
import earlyAccessLinks from './contextualizers/early-access-links.js'
@@ -182,6 +183,7 @@ export default function (app) {
182183
// *** Rendering, 2xx responses ***
183184
app.use('/events', asyncMiddleware(instrument(events, './events')))
184185
app.use('/search', asyncMiddleware(instrument(search, './search')))
186+
app.use('/healthz', asyncMiddleware(instrument(healthz, './healthz')))
185187

186188
// Check for a dropped connection before proceeding (again)
187189
app.use(haltOnDroppedConnection)

0 commit comments

Comments
 (0)