如何提高NodeJS程序运行的稳定性

 

我们常通过node app.js方式运行nodejs程序,但总有一些异常或错误导致程序运行停止退出。如何保证node程序的稳定运行?

下面是一些可以考虑的方案:

1.使用最新的node版本程序。
2.使用try{...} catch(error){...}。
3.使用domains。
4.使用forever,upstart,monit,supervisor,mother.js等。
5.使用cluster。
6.使用 process.on('uncaughtException', function(err){...}); 来处理未被捕捉的错误。


参考:

 

http://shapeshed.com/uncaught-exceptions-in-node/ Uncaught Exceptions in Node.js

http://cnodejs.org/topic/4f16442ccae1f4aa270010e7 如何提高NodeJS程序的稳定性

http://deadhorse.me/nodejs/2013/04/13/exception_and_domain.html   Node.js 异步异常的处理与domain模块解析

 

http://nodejs.org/api/process.html#process_event_uncaughtexception

http://nodejs.org/api/domain.html

 

https://github.com/fengmk2/domain-middleware

https://github.com/fengmk2/graceful

https://github.com/FGRibreau/forever-webui

相关文章:

  • 2021-06-24
  • 2021-07-26
  • 2021-11-26
  • 2022-12-23
  • 2022-02-07
  • 2021-04-05
  • 2021-12-03
  • 2021-05-25
猜你喜欢
  • 2021-11-07
  • 2021-09-15
  • 2021-08-10
  • 2021-12-26
  • 2021-10-14
  • 2022-01-16
相关资源
相似解决方案