我正在按照这里的指导(监听SIGINT事件)来优雅地关闭我的Windows-8托管的node.js应用程序以响应Ctrl-C或服务器关闭.
但Windows没有SIGINT.我也试过process.on('exit'),但似乎迟到做任何有成效的事情.
在Windows上,这段代码告诉我:错误:没有这样的模块
process.on( 'SIGINT', function() {
console.log( "\ngracefully shutting down from SIGINT (Crtl-C)" )
// wish this worked on Windows
process.exit( )
})
Run Code Online (Sandbox Code Playgroud)
在Windows上,此代码运行,但为时已晚,无法做任何优雅的事情:
process.on( 'exit', function() {
console.log( "never see this log message" )
})
Run Code Online (Sandbox Code Playgroud)
SIGINTWindows上有同等的事件吗?