express-process-manager

Abstracts initialisation and shutdown of Express.js services.

OTHER License

Downloads
8
Stars
5
Committers
1

express-process-manager

Abstracts initialisation and shutdown of Express.js services.

Disclaimer: I just needed something that works for my Kubernetes setup. This is far from a customisable service that could work across many projects in different environments.

A new project has been launched since: https://github.com/gajus/lightship

Behaviour

Creates /healthz health-check endpoint.

The health-check endpoint responds:

  • 500 status code, message "SERVER IS NOT READY" when server is initialising.
  • 500 status code, message "SERVER IS SHUTTING DOWN" when server is shutting down.
  • 200 status code, message "OK" when server is accepting new connections.

The default behaviour is:

  • Service becomes ready 5 seconds after initialisation of the process manager.
  • Service enters graceful shutdown after receiving SIGTERM. Service shutdowns after 5 seconds.

Usage

import express from 'express';
import {
  createProcessManager
} from 'express-process-manager';

const app = express();

const server = app.listen(8080);

createProcessManager(server, app);

Kubernetes readiness and liveness probe configuration

readinessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 5
  initialDelaySeconds: 5
livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  periodSeconds: 5
  initialDelaySeconds: 10

Package Rankings
Top 22.56% on Npmjs.org
Badges
Extracted from project README
Travis build status NPM version Canonical Code Style Twitter Follow
Related Projects