相关疑难解决方法(0)

如何在SIGINT上停止node.js检查器/ Chrome调试器?

我有以下代码从终端捕获^ C并正常关闭我的Express应用程序:

process.on('SIGINT', () => {
    console.log('SIGINT received ...');
    console.log('Shutting down the server');

    server.close(() => {
        console.log('Server has been shutdown');
        console.log('Exiting process ...');
        process.exit(0);
    });
});
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用启动节点实例--inspect,则上述代码无法停止检查器和Chrome调试器.当我重新启动我的应用程序时,我收到以下错误:

Starting inspector on 127.0.0.1:9229 failed: address already in use
Run Code Online (Sandbox Code Playgroud)

如何优雅地停止我的应用程序以避免此错误?

可以使用完整的代码在这里.

node.js express node-inspector

13
推荐指数
2
解决办法
1万
查看次数

标签 统计

express ×1

node-inspector ×1

node.js ×1