简体   繁体   English

节点进程结束后,Grunt(保持活动状态)没有退出

[英]Grunt (keep-alive) does not exit after the node process ends

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)

But even after this the grunt process keep running. 但是即使在此之后,发出刺耳的声音的过程仍然继续。 I have set grunt serve:dist to run as an upstart job but it won't respawn till the grunt process ends. 我已经将grunt serve:dist设置为新贵的工作,但是直到grunt进程结束,它才会重新生成。 I am catching all process errors and making sure the node process exits. 我正在捕获所有进程错误,并确保节点进程退出。

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

A ps aux returns that there are no node process running. ps aux返回没有正在运行的节点进程。

From the node documentation on uncaughtException : uncaughtException的节点文档中:

Note that uncaughtException is a very crude mechanism for exception handling. 请注意,uncaughtException是异常处理的一种非常粗糙的机制。

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. 不要将其用作等效于On Error Resume Next的node.js。 An unhandled exception means your application - and by extension node.js itself - is in an undefined state. 未处理的异常意味着您的应用程序-扩展名为node.js本身-处于未定义状态。 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. 你被警告了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM