mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-09 11:37:05 +00:00
feat(healthcheck): add /_health endpoint
This endpoint returns the internal readiness state used by the realtime code to indicate whether HedgeDoc is performing properly. As it only returns the state of a variable, it is less resource hungry compared to a call to /status for checking the health of HedgeDoc. By prepending the route with an underscore, it should not be conflicting with already created pads in FreeURL mode. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
4cf56bfdca
commit
9949e3a875
3 changed files with 12 additions and 1 deletions
2
app.js
2
app.js
|
@ -181,7 +181,7 @@ app.use(flash())
|
|||
|
||||
// passport
|
||||
app.use(passport.initialize())
|
||||
app.use(useUnless(['/status', '/metrics'], passport.session()))
|
||||
app.use(useUnless(['/status', '/metrics', '/_health'], passport.session()))
|
||||
|
||||
// check uri is valid before going further
|
||||
app.use(require('./lib/web/middleware/checkURIValid'))
|
||||
|
|
|
@ -12,6 +12,16 @@ const { urlencodedParser } = require('./utils')
|
|||
|
||||
const statusRouter = module.exports = Router()
|
||||
|
||||
statusRouter.get('/_health', function (req, res) {
|
||||
res.set({
|
||||
'Cache-Control': 'private', // only cache by client
|
||||
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
|
||||
})
|
||||
res.send({
|
||||
ready: !realtime.maintenance
|
||||
})
|
||||
})
|
||||
|
||||
// get status
|
||||
statusRouter.get('/status', function (req, res, next) {
|
||||
realtime.getStatus(function (data) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
### Enhancements
|
||||
- Extend boolean environment variable parsing with other positive answers and case insensitivity.
|
||||
- Allow setting of `documentMaxLength` via `CMD_DOCUMENT_MAX_LENGTH` environment variable.
|
||||
- Add dedicated healthcheck endpoint at /_health that is less resource intensive than /status.
|
||||
|
||||
## <i class="fa fa-tag"></i> 1.9.7 <i class="fa fa-calendar-o"></i> 2023-02-19
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue