What is the Windows equivalent of process.on('SIGINT') in node.js?

前端 未结 6 1336
北海茫月
北海茫月 2020-11-28 02:47

I\'m following the guidance here (listening for SIGINT events) to gracefully shutdown my Windows-8-hosted node.js application in response to Ctrl+

6条回答
  •  长情又很酷
    2020-11-28 03:35

    I'm not sure as of when, but on node 8.x and on Windows 10 the original question code simply works now.

    process.on( "SIGINT", function() {
      console.log( "\ngracefully shutting down from SIGINT (Crtl-C)" );
      process.exit();
    } );
    
    process.on( "exit", function() {
      console.log( "never see this log message" );
    } );
    
    setInterval( () => console.log( "tick" ), 2500 );
    

    also works with a windows command prompt.

提交回复
热议问题