sopalin
v1.0.1
Published
A uncaught exception handler for hapi that triggers a graceful shutdown.
Downloads
3
Readme
sopalin
Wipe up spilled milk in Hapi.
A plugin to shutdown on uncaughtExceptions, while allowing in-flight responses to complete. While the server is shutting down,
new requests will be responded to with a 503.
Registration options
replyHeaders- Response headers to return post error, while the server is still shutting down. Defaults to{}.shutdownTimeout- Timeout option for Hapi.Server#stop. Defaults to10000.lastly(error)- An optional final callback for clean up. Called after server shutdown. The default behavior is toprocess.exit(1).
Usage
const Hapi = require('hapi');
const Sopalin = require('sopalin');
const server = new Hapi.Server();
server.register({
register: Sopalin,
options: {
shutdownTimeout: 15000,
replyHeaders: {
'x-custom-retry-header': 'true'
}
}
}, (error) => {
//Everything else...
});