@forrestjs/service-fastify-healthz (英语)
ForrestJS服务,帮助建立快速健康检查路线.
戴莫:
https://codesandbox.io/s/ service-fastify-healthz-4g3my 互联网档案馆的存檔,存档日期2013-12-22
安装设置( S)
npm add @forrestjs/core @forrestjs/service-fastify @forrestjs/service-fastify-healthz
在您的 FastifyJS App 中设置:
// index.js
const forrestjs = require('@forrestjs/core');
const fastifyService = require('@forrestjs/service-fastify');
const fastifyHealthzService = require('@forrestjs/service-fastify-healthz');
// Run the app:
forrestjs.run({
services: [fastifyService, fastifyHealthzService],
});
配置 & ENVs
固态化. healthz.method
默认 : GET
固态化. healthz.url
默认 : /healthz
扩展
$FASTIFY HAALTHZ 韩德勒
此钩子允许覆盖默认的健康检查路径 .
如果您想在健康检查中表现出丰富的逻辑, 这会很有帮助 .
// Create a custom healthcheck response
const HEALTHZ_MSG = 'This is a custom healthcheck response';
const customHealthz = ({ registerHandler }) =>
registerHandler(async () => HEALTHZ_MSG);
forrestjs.run({
features: [
{
target: '$FASTIFY_HEALTHZ_HANDLER',
handler: customHealthz,
},
],
});