Socket
Book a DemoInstallSign in
Socket

@microservice/koa-terminator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microservice/koa-terminator

Terminate a service as gracefully as possible on error; does not travel through time.

3.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

microservice / terminator

shuts down the server if an error occurs. tries to be nice about it.

usage

first, register the middleware

const terminator = require('@microservice/koa-terminator');

app.use(require('koa-error')); // catch errors and display error pages like normal
app.use(terminator()); // this will signal termination on uncaught errors
// everything else comes after

then, listen for a terminate event

const server = app.listen();

process.on('terminate', () => {
  // the process will exit once existing connections are done
  server.close();
  // you could use a timeout here to force shutdown as well.
  const timer = setTimeout(() => {
    process.exit(1);
  }, 5000);
  timer.unref();
})

FAQs

Package last updated on 29 Jun 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.