Socket
Socket
Sign inDemoInstall

server-shutdown

Package Overview
Dependencies
4
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

3

package.json
{
"name": "server-shutdown",
"version": "0.1.0",
"version": "0.2.0",
"description": "Gracefully shutdown any number of HTTP and WebSocket servers in node",

@@ -39,3 +39,2 @@ "main": "src/index.js",

"devDependencies": {
"async": "^2.1.2",
"chai": "^3.5.0",

@@ -42,0 +41,0 @@ "eslint": "^3.8.1",

@@ -6,3 +6,3 @@ # Server Shutdown

[![Coverage Status](https://coveralls.io/repos/github/MitMaro/node-server-shutdown/badge.svg?branch=master)](https://coveralls.io/github/MitMaro/node-server-shutdown?branch=master)
[![NPM version](https://img.shields.io/npm/v/node-server-shutdown.svg)](https://www.npmjs.com/package/node-server-shutdown)
[![NPM version](https://img.shields.io/npm/v/server-shutdown.svg)](https://www.npmjs.com/package/server-shutdown)
[![GitHub license](https://img.shields.io/badge/license-ISC-blue.svg)](https://raw.githubusercontent.com/MitMaro/node-server-shutdown/master/LICENSE.md)

@@ -49,9 +49,16 @@

## Adding Socket.io
// continuing from basic uasge
const socketio = require('socket.io');
const io = socketio(httpServer);
serverShutdown.registerServer(io.engine);
## API
### `registerServer(server)`
### `ServerShutdown.registerServer(server)`
Registers a server with the library.
### `shutdown([force = false][, callback])`
### `ServerShutdown.shutdown([force = false][, callback])`

@@ -58,0 +65,0 @@ Shutdown all the servers registered. If the optional `force` flag is provided and true all connections

@@ -6,4 +6,5 @@ 'use strict';

function noop() { } // eslint-disable-line no-empty-function
function noop() {
// this function does nothing
}
class ServerShutdown {

@@ -106,3 +107,4 @@ constructor() {

debug('Destroying socket');
socket.destroy();
// Some sockets use close (engine.io), Node.js uses destroy
(socket.destroy || socket.close).call(socket);
this.sockets.delete(socket);

@@ -109,0 +111,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc