gpt4 book ai didi

javascript - Node 进程结束后Grunt(keep-alive)不退出

转载 作者:行者123 更新时间:2023-12-03 10:27:36 26 4
gpt4 key购买 nike

Running "express-keepalive" task
[::ffff:xx.xx.xx.xx] CONNECTED
Caught exception: Error: connect ETIMEDOUT
Error: connect ETIMEDOUT
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)

但即使在此之后,grunt 进程仍继续运行。我已将 gruntserve:dist 设置为作为 Upstart 作业运行,但在 grunt 进程结束之前它不会重生。我正在捕获所有进程错误并确保 Node 进程退出。

process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
console.log(err.stack);
process.exit(1);
});

ps aux 返回没有 Node 进程正在运行。

最佳答案

来自关于 uncaughtException 的 Node 文档:

Note that uncaughtException is a very crude mechanism for exception handling.

Don't use it, use domains instead. If you do use it, restart your application after every unhandled exception!

Do not use it as the node.js equivalent of On Error Resume Next. An unhandled exception means your application - and by extension node.js itself - is in an undefined state. Blindly resuming means anything could happen.

Think of resuming as pulling the power cord when you are upgrading your system. Nine out of ten times nothing happens - but the 10th time, your system is bust.

You have been warned.

关于javascript - Node 进程结束后Grunt(keep-alive)不退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29347077/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com