npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hyperbyte-io/nodejs-livez-readyz

v1.8.6

Published

Healthcheck endpoints (/livez and /readyz) for nodejs applications

Downloads

1

Readme

Nodejs Healthcheck

A library for adding standard (k8s) healthchecks to nodejs applications. based on nodejs-healthcheck

It exposes 2 endpoints:

  1. /health/livez - Returns 200 by default , can optionally include result evaluating all readyz passed in config.
  2. /health/readyz - Returns 200 by default , can optionally include result evaluating all readyz passed in config.

Usage

Configure an express.js handler with checks.

const healthcheck = require('@hyperbyte-io/nodejs-livez-readyz');

const config = {
    livez: {
        myComplexWebCheck: healthcheck.web('https://example.com/other', {
            callback: (err, res) => {
                return res.body.status == 'good'
                    ? healthcheck.up()
                    : healthcheck.down();
            },
            timeout: 5000,
            deadline: 10000
        }),
        myRawCheck: healthcheck.raw(() => {
            return myInternalCheck() ? healthcheck.up() : healthcheck.down();
        })
    },
    readyz: {
        mySimpleWebCheck: healthcheck.web('https://example.com/status'),
        myComplexWebCheck: healthcheck.web('https://example.com/other', {
            callback: (err, res) => {
                return res.body.status == 'good'
                    ? healthcheck.up()
                    : healthcheck.down();
            },
            timeout: 5000,
            deadline: 10000
        }),
        myRawCheck: healthcheck.raw(() => {
            return myInternalCheck() ? healthcheck.up() : healthcheck.down();
        })
    }
};
healthcheck.addTo(app, config);

what to include in readiness checks

  • On Kubernetes, readiness probes will be called periodically throughout the lifetime of the container. Container will be made temporarily unavailable from serving traffic when the readiness check fails.
  • The requests won't even reach your application to handle errors. So, it is very important to consider what checks should be included into readiness probe.
  • While adding all dependant services to readiness check can help in identifying any misconfiguration during startup, it could cause unwanted downtime for the application.
  • K8s introduced startUp Probes (Alpha in 1.16 ) to handle startup cases separately.

Based on above, you should include a dependency into readiness checks only if they are exclusive/hard dependencies for your service. Unavailability of soft dependencies needs to be handled in code to give appropriate customer experience.

Good example for check to be included in readiness:

  • A private cache / database like Redis or Elastic Search which are exclusive to the application (not shared).

Bad example for check to be included in readiness:

  • Any shared components like IDAM, S2S or CCD.