mtr-health
v1.0.0
Published
Library ini akan melakukan pengecekan tiap service ### Dependency Library ini menggunakan package [**@godaddy/terminus v4.1.2**](https://www.npmjs.com/package/@godaddy/terminus). ### Installation ```bash npm i git+ssh://[email protected]/mt
Downloads
3
Readme
Health Check Library
Library ini akan melakukan pengecekan tiap service
Dependency
Library ini menggunakan package @godaddy/terminus v4.1.2.
Installation
npm i git+ssh://[email protected]/mtr-platform/libs/health
Penggunaan
Deklarasikan module library di dalam file index.js
.
const healthz = require('mtr-health');
const { env } = process;
const svc = env.SVC_NAME || 'Meteor';
const host = env.HOST || 'localhost';
const port = Number(env.PORT) || 3000;
const server = http.createServer(app);
const conParam = { timeout, extFuncOnSignal, extFunconShutdown, extFuncbeforeShutdown, extFunchealthChecks };
// extFuncOnSignal is a function or array of extended functions(s) to run on 1st line
// extFunconShutdown is a function or array of extended functions(s) to run on 1st line
// extFuncbeforeShutdown is a function or array of extended functions(s) to run on 1st line
// extFunchealthChecks is a function or array of extended functions(s) to run on 1st line
if (process.env.NODE_ENV === 'production') healthz.healthCheck(server, conParam);
server.listen(port)
.on('error', err => healthz.onError(err, port))
.on('listening', () => healthz.onListening(svc, host, port, extFuncListen));
// extFuncError is a function or array of extended functions(s) to run on 1st line
// extFuncListen is a function or array of extended functions(s) to run on 1st line