Socket
Socket
Sign inDemoInstall

@godaddy/terminus

Package Overview
Dependencies
Maintainers
12
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@godaddy/terminus

[![Join Slack](https://img.shields.io/badge/Join%20us%20on-Slack-e01563.svg)](https://godaddy-oss-slack.herokuapp.com/) [![Build Status](https://github.com/godaddy/terminus/actions/workflows/cicd.yml/badge.svg)](https://github.com/godaddy/terminus/actions


Version published
Weekly downloads
167K
decreased by-3.44%
Maintainers
12
Weekly downloads
 
Created

What is @godaddy/terminus?

@godaddy/terminus is a Node.js package that helps manage graceful shutdowns and health checks for your applications. It ensures that your application can handle termination signals properly, allowing for clean shutdowns and preventing data corruption or loss. It also provides endpoints for health checks to monitor the application's status.

What are @godaddy/terminus's main functionalities?

Graceful Shutdown

This feature allows the application to handle termination signals gracefully. When a termination signal (e.g., SIGINT) is received, the `onSignal` function is called to perform any necessary cleanup before the server shuts down.

const http = require('http');
const { createTerminus } = require('@godaddy/terminus');

const server = http.createServer((req, res) => {
  res.end('Hello world!');
});

function onSignal() {
  console.log('Server is starting cleanup');
  // start cleanup of resource, like databases or file descriptors
  return Promise.resolve();
}

function onShutdown() {
  console.log('Cleanup finished, server is shutting down');
}

createTerminus(server, {
  signal: 'SIGINT',
  onSignal,
  onShutdown
});

server.listen(3000);

Health Checks

This feature provides a health check endpoint that can be used to monitor the application's status. The `onHealthCheck` function can include logic to determine if the application is healthy and return a promise that resolves if it is.

const http = require('http');
const { createTerminus } = require('@godaddy/terminus');

const server = http.createServer((req, res) => {
  res.end('Hello world!');
});

function onHealthCheck() {
  return Promise.resolve(); // optionally include a health check here
}

createTerminus(server, {
  healthChecks: {
    '/healthcheck': onHealthCheck
  }
});

server.listen(3000);

Other packages similar to @godaddy/terminus

FAQs

Package last updated on 16 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc