浏览代码

feat: healthz endpoint

Nick 6 年之前
父节点
当前提交
9f87535a03
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      server/controllers/common.js

+ 11 - 0
server/controllers/common.js

@@ -17,6 +17,17 @@ router.get('/robots.txt', (req, res, next) => {
   }
 })
 
+/**
+ * Health Endpoint
+ */
+router.get('/healthz', (req, res, next) => {
+  if (WIKI.models.knex.client.pool.numFree() < 1 && WIKI.models.knex.client.pool.numUsed() < 1) {
+    res.status(503).json({ ok: false }).end()
+  } else {
+    res.status(200).json({ ok: true }).end()
+  }
+})
+
 /**
  * Create/Edit document
  */