![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
server-shutdown
Advanced tools
Gracefully shutdown any number of HTTP and WebSocket servers in node
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.
Using just 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
into 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 = require('http');
const https = require('https');
const ServerShutdown = require('server-shutdown');
const serverShutdown = new ServerShutdown();
const httpServer = http.createServer((req, res) => {
res.end('HTTP response');
}).listen(80);
const httpsServer = https.createServer((req, res) => {
res.end('HTTPS response');
}).listen(443);
serverShutdown.registerServer(httpServer);
serverShutdown.registerServer(httpsServer);
process.on('SIGTERM', () => {
serverShutdown.shutdown(() => {
console.log('All servers shutdown gracefully');
});
});
// continuing from basic uasge
const socketio = require('socket.io');
const io = socketio(httpServer);
serverShutdown.registerServer(io, ServerShutdown.Adapters.socketio);
This library uses debug to produce debugging output. To enable add DEBUG=server-shutdown
before
your run command.
This project is released under the ISC license. See LICENSE.
[2.0.0] - 2018-11-18
FAQs
Gracefully shutdown any number of HTTP and WebSocket servers in node
The npm package server-shutdown receives a total of 145 weekly downloads. As such, server-shutdown popularity was classified as not popular.
We found that server-shutdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.