![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.
hapi-pulse
Advanced tools
hapi plugin to gracefully stop your hapi server
Installation · Usage · Plugin Options
Follow @marcuspoehls for updates!
The Future Studio University supports development of this hapi plugin 🚀
Join the Future Studio University and Skyrocket in Node.js
A hapi plugin that gracefully stops the hapi server on SIGINT
and SIGTERM
and your custom signals.
hapi-pulse
works great with PM2 and other Node.js process manager to accomplish zero-downtime deployments!
This serves existing requests before closing the connection and stopping the hapi server process.
It uses hapi’s server.stop()
method to close connections properly.
hapi v19 (or later) and Node.js v12 (or newer)
This plugin requires hapi v19 (or later) and Node.js v12 or newer.
Major Release | hapi.js version | Node.js version |
---|---|---|
v3 | >=17 hapi | >=12 |
v2 | >=17 hapi | >=8 |
Add hapi-pulse
as a dependency to your project:
npm i hapi-pulse
The most straight forward way to register the hapi-pulse
plugin:
await server.register({
plugin: require('hapi-pulse'),
options: {
// any option that is supported by hapi's "server.stop()"
timeout: 15000,
// plugin specific options
logger: console,
signals: ['SIGINT'],
postServerStop: async function () {
// await Database.close()
}
}
})
hapi-pulse
passes the options through to hapi’s server.stop(options)
.
Customize the behavior of server.stop()
, like the timeout
before forcefully stopping the process.
Additionally, you can pass along the following options:
(Object)
, default: console
— in case of an error, hapi-pulse logs the error with logger.error('message', error)
(Array)
, default: ['SIGINT', 'SIGTERM']
— use this signals
option to customize the events on which hapi-pulse will stop the server(Function)
, default: Promise.resolve
— an async function that runs before server.stop()
(Function)
, default: Promise.resolve
— an async function that runs after server.stop()
(Function)
, default: Promise.resolve
— an async function that runs after postServerStop()
and before process.exit
(int)
, default: 5000 (5 seconds)
— the timeout existing connections should be closed until they are forcefully interrupted. This option is passed through to hapi’s server.stop()
Example
await server.register({
plugin: require('hapi-pulse'),
options: {
timeout: 25 * 1000,
logger: console,
signals: ['SIGINT', 'SIGTERM'],
preServerStop: async function () {
// this runs before server.stop()
},
postServerStop: async function () {
// this runs after server.stop()
// e.g., await Database.close()
},
preShutdown: async function () {
// this runs after postServerStop() and before process.exit
}
}
})
// went smooth like chocolate :)
Do you miss a feature? Please don’t hesitate to create an issue with a short description of your desired addition to this plugin.
git checkout -b my-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT © Future Studio
futurestud.io · GitHub @futurestudio · Twitter @futurestud_io
FAQs
hapi plugin that gracefully stops the hapi server on SIGINT
The npm package hapi-pulse receives a total of 2,391 weekly downloads. As such, hapi-pulse popularity was classified as popular.
We found that hapi-pulse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
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.