🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

http-shutdown

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-shutdown

Gracefully shutdown a running HTTP server.

1.2.2
latest
Version published
Weekly downloads
1.1M
6.12%
Maintainers
1
Weekly downloads
 
Created

What is http-shutdown?

The http-shutdown npm package extends the standard Node.js HTTP server with a shutdown method. This allows you to gracefully shut down the server, ensuring that all existing connections are served before the server is closed.

What are http-shutdown's main functionalities?

Graceful Shutdown

This feature allows you to add a shutdown method to your HTTP server instance. When called, it will not accept new connections and will wait for all existing connections to end before shutting down the server.

const http = require('http');
const enableShutdown = require('http-shutdown');

const server = enableShutdown(http.createServer((req, res) => {
  res.writeHead(200);
  res.end('Hello World!');
}));

server.listen(3000);

// Shutdown the server after 10 seconds
setTimeout(() => {
  server.shutdown(() => {
    console.log('Server is gracefully shut down.');
  });
}, 10000);

Other packages similar to http-shutdown

FAQs

Package last updated on 10 Jan 2020

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