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

4 years ago
  1. 'use strict';
  2. const signals = ['SIGINT', 'SIGTERM'];
  3. function setupExitSignals(serverData) {
  4. signals.forEach((signal) => {
  5. process.on(signal, () => {
  6. if (serverData.server) {
  7. serverData.server.close(() => {
  8. // eslint-disable-next-line no-process-exit
  9. process.exit();
  10. });
  11. } else {
  12. // eslint-disable-next-line no-process-exit
  13. process.exit();
  14. }
  15. });
  16. });
  17. }
  18. module.exports = setupExitSignals;