
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
graceful-shutdown
Advanced tools
Gracefully shutdown a server upon receiving the specified signal(s)
#graceful-shutdown
Shuts down a Server
gracefully upon the first specified signal received by the process and executes the optional callback.
var gracefullyShutdown = require('graceful-shutdown');
var server = http.createServer();
gracefullyShutdown(server).upon('SIGINT SIGTERM').on('shutting-down', function() {
console.log('server#close() has been called');
});
graceful-shutdown
exports a single constructor. It may be called with or without the new
keyword.
var GracefulShutdown = require('graceful-shutdown');
// these are the same:
var gs = GracefulShutdown(server);
var gs = new GracefulShutdown(server);
The constructor accepts a single net.Server
instance.
Accepts either a space delimited list of events or an array of event names. Listeners for these events will be added to the process
. Once any one of these events are emitted on the process
, server.close()
will be executed, and all registered event listeners will be removed.
// these are the same
var gs = GracefulShutdown(server).upon('SIGTERM SIGINT');
var gs = GracefulShutdown(server).upon(['SIGTERM', 'SIGINT']);
The GracefulShutdown instance will emit a shutting-down
event when server.close()
has been called.
Note, this is not a listener for the server close event. If you want to listen for the server close
event you must add the listener yourself.
GracefulShutdown(server).upon('SIGTERM SIGINT').on('shutting-down', function() {
console.log('server.close() has been called');
});
server.on('close', console.log.bind(console, 'the server is closed'));
An alternative way to register a callback for the shutting-down
event is to pass it as the second argument to GracefulShutdown.
GracefulShutdown(server, callback).upon('SITERM SIGINT');
npm install graceful-shutdown
MIT
FAQs
Gracefully shutdown a server upon receiving the specified signal(s)
The npm package graceful-shutdown receives a total of 0 weekly downloads. As such, graceful-shutdown popularity was classified as not popular.
We found that graceful-shutdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.