Add support for SIGINT and SIGTERM handling

Currently, server run by `node index.js` is not able to handle SIGTERM or SIGINT properly. The only fate is being killed. This change adds basic handling logic for these two signals, helping server to behave more properly as expected by many daemons and users.
This commit is contained in:
Ying Kanyang (Harry Ying) 2020-08-28 22:07:25 +08:00 committed by GitHub
parent 9c1fb153df
commit f9bace9a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,16 @@
var process = require('process')
// Handle SIGINT
process.on('SIGINT', () => {
console.info("SIGINT Received, exiting...")
process.exit(0)
})
// Handle SIGTERM
process.on('SIGTERM', () => {
console.info("SIGTERM Received, exiting...")
process.exit(0)
})
const parser = require('ua-parser-js');
const { uniqueNamesGenerator, animals, colors } = require('unique-names-generator');