lbstatus plugin for hapi

Usage no npm install needed!

<script type="module">
  import hapiLbstatus from 'https://cdn.skypack.dev/hapi-lbstatus';


Hapi lbstatus

Build Status NPM version Dependencies

Shared code for the _lbstatus endpoint. Essentially a poor-man's service discovery, will be used until the front-door service is ready.

Reads the specified file and looks for the value 'ON' or 'OFF' and returns ON or OFF from the endpoint.

If the file is missing, or empty, or an exception occurs, then default value is OFF.

Also performs a liveness check by injecting a request to a specified endpoint (using server.inject). If the response is an error (or times out) it returns "OFF".


npm install hapi-lbsstatus


var server = hapi.createServer();

    file: '/etc/lbstatus/myappname',
    liveness: '/my/api/123',
    headers: {
    // optional headers to apply when making the liveness check
      'accept-language': 'en-US'
    on: "MYAPP_ON", // override the default return value of 'ON'
    off: "MYAPP_OFF" // override the default return value of 'OFF'
  function (err){
      throw err;

// also exposes the lbstatus function

  // returns true if ON, false if OFF

Response Codes:

  • ON: 200
  • OFF: 503


  • Supports pack servers as well as single instances
  • Supports hapi v5+