You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
472 B
21 lines
472 B
'use strict';
|
|
|
|
const signals = ['SIGINT', 'SIGTERM'];
|
|
|
|
function setupExitSignals(serverData) {
|
|
signals.forEach((signal) => {
|
|
process.on(signal, () => {
|
|
if (serverData.server) {
|
|
serverData.server.close(() => {
|
|
// eslint-disable-next-line no-process-exit
|
|
process.exit();
|
|
});
|
|
} else {
|
|
// eslint-disable-next-line no-process-exit
|
|
process.exit();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = setupExitSignals;
|
|
|