Giter Site home page Giter Site logo

chairo-health-check's Introduction

chairo-health-check

npm version Build Status Coverage Status NSP Status

Add a simple health check to your chairo/seneca service. Includes the ability to check which version of your service is running.

Usage

const Chairo = require('chairo')
const HealthCheck = require('chairo-health-check')
const { name, version } = require('./package.json')

const HealthCheckPlugin = {
  register: HealthCheck,
  options: {
    name, // Optional. Default: $npm_package_name
    version, // Optional. Default: $npm_package_version
    action: {  // Optional. Default shown here
      role: 'health',
      cmd: 'check',
    },
    promise: Promise.resolve('testing'),
  },
}

server.register([Chairo, HealthCheckPlugin], (error) => {

  if (error) return server.log(['error'], error)

  return server.start(() => {

    server.log(['info'], `Server running at: ${server.info.uri}`)

  })

})

Example result:

{
  "info": {
    "created": 1476044745024,
    "started": 0,
    "host": "mylaptop.local",
    "port": 0,
    "protocol": "http",
    "id": "mylaptop.local:61289:iu32xidc",
    "uri": "http://mylaptop.local"
  },
  "name": "my-seneca-service",
  "ready": true,
  "version": "1.0.0",
  "promise": "testing"
}

Options

The following configuration options are available:

  • name - The name to be returned from the health check. Default: process.env.npm_package_name
  • version - The version to be returned from the health check. Default: process.env.npm_package_version
  • action - The pattern used to call the health check. Default: { role: 'health', cmd: 'check }
  • promise - A promise to be resolved and the returned value added to a promise property on the result message.

chairo-health-check's People

Contributors

tribou avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.