server-shutdown
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"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 @@ } |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8621
7
102
87
1