我遵循 给你(监听 SIGINT
事件)的指导,在响应 Ctrl + C或服务器关闭时,优雅地关闭我的 Windows-8托管的 node.js 应用程序。
但是 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( )
})
在 Windows 上,这段代码运行,但是是 做任何优雅的事情都太晚了:
process.on( 'exit', function() {
console.log( "never see this log message" )
})
在 Windows 上是否有 SIGINT
等效事件?