Как в node js сделать 'graceful shutdown', когда нажимаешь на крестик консоли Windows

Получается ни process on exit, ни process on SIGTERM событие не срабатывает на крестик, а приложение просто закрывается.

.on('SIGHUP', function () {…});
́
«'SIGTERM' is not supported on Windows, it can be listened on.»
«'SIGHUP' is generated on Windows when the console window is closed, and on other platforms under various similar conditions, see signal(7). It can have a listener installed, however Node.js will be unconditionally terminated by Windows about 10 seconds later. On non-Windows platforms, the default behavior of SIGHUP is to terminate Node.js, but once a listener has been installed its default behavior will be removed.»

Добавить комментарий