exframe-service

1.6.2 • Public • Published

exframe Service Module

Manage SIGTERM shutdown request

Features

  • Built in creation of health checks for external GET endpoints
  • Custom creaton of health checks where the built in health check doesn't meet requirements
  • Automatically captures prometheus metrics for the running process

Use

const service = require('exframe-service');

Full Example

const service = require('exframe-service');
const logger = require('exframe-logger').create(process.env.LOGSENE_TOKEN || 'token');

const onSignalMQ = () => {
  return new Promise((resolve, reject) => {
    logger.debug('run mq cleanup code');
  });
};

const onSignalRest = () => {
  return new Promise((resolve, reject) => {
    logger.debug('run rest cleanup code');
  });
};

service.init({ logger, timeout: 10000 });

service.registerResource('db', { onSignal: onSignalDB, order: 'last' });
service.registerResource('mq', { onSignal: onSignalMQ });
service.registerResource('rest', { onSignal: onSignalRest });
};

Methods

init()

Syntax

service.init({ logger, timeout: 5000 })

Parameter Values

  • logger Required. logger object.

  • timeout Optional. wait time before exframe-service alerts registered node modules to shutdown (defaults to 10 seconds).

registerResource()

Syntax

service.registerResource('mq', { onSignal: onSignalMQ })

Parameter Values

  • name Required. name of registered service.

  • { onSignal } Required. cleanup function that returns a promise.

/exframe-service/

    Package Sidebar

    Install

    npm i exframe-service

    Weekly Downloads

    1,168

    Version

    1.6.2

    License

    ISC

    Unpacked Size

    45.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • exzeo_usa
    • exzeodevops