@godaddy/terminus
Version:
[](https://godaddy-oss.slack.com/) [](https://github.com/godaddy/terminus/actions/workflows
23 lines (19 loc) • 522 B
JavaScript
const http = require('http')
const server = http.createServer((req, res) => res.end('hello'))
const { createTerminus } = require('../../')
const SIGNALS = ['SIGUSR2', 'SIGINT', 'SIGTERM']
const SIGNAL = process.argv[2]
createTerminus(server, {
signals: SIGNALS,
onSignal: () => {
console.log('on-' + SIGNAL.toLowerCase() + '-runs')
return Promise.resolve()
},
onShutdown: () => {
console.log('on-shutdown-runs')
}
})
server.listen(8000, () => {
process.kill(process.pid, SIGNAL)
})