This package has been deprecated
Package is no longer supported. See Stoppable for an alternative.
At some point, Socket.IO started correctly handling active connections on shutdown. Since the main purpose of this library was to add support for gracefully shutting down a Socket.IO server, I've decided to cease development on this project. It should be easy to replace the usage of this library with the maintained library Stoppable.
server.close only terminates the server once every connection is closed. This is problematic since,
by design, keep-alive connections can continue to hold the server open, and WebSockets can hold the connection open
for extended periods of time. A naive solution forcefully destroys all the sockets, interrupting any inflight requests.
Another solution is to
server.unref the server, but this isn't a satisfactory solution as it does not allow the
close event to be used.
This library solves this problem by tracking when a connection is busy, using
request for HTTP connections, and hooking
write in the case of WebSockets. The server shutdowns by first stopping any additional connections being made,
closing any idle HTTP and WebSocket connections, closing any busy HTTP connections once the inflight request has completed, and
closing WebSocket connections on finish of a write.
npm install --save server-shutdown
const http = ;const https = ;const ServerShutdown = ;const serverShutdown = ;const httpServer = http;const httpsServer = https;serverShutdown;serverShutdown;process;
// continuing from basic uasgeconst socketio = ;const io = ;serverShutdown;
This library uses debug to produce debugging output. To enable add
your run command.
This project is released under the ISC license. See LICENSE.