简体   繁体   English

For Multiple Request Node.js中的Jxcore错误处理

[英]Jxcore Error handling in For Multiple Request Nodejs

i am running a nodejs code (server.js) as a jxcore using jx mt-keep:4 server.js 我正在使用jx mt-keep:4 server.js作为jxcore运行nodejs代码(server.js)

we have a lot of request hit per seconds and mostly transaction take place. 我们每秒钟有很多命中请求,并且大部分是交易发生。 I am looking for a way to catch error incase any thread dies and the request information is returned back to me so that i can catch that request and take appropriate action based on it. 我正在寻找一种方法来捕获错误,以防任何线程死亡并且请求信息返回给我,以便我可以捕获该请求并根据该请求采取适当的措施。 So in this i might not lose teh request coming in and would handle it. 因此,在这种情况下,我可能不会丢失请求并会处理它。

This is a nodejs project and due to project urgency has been moved to jxcore. 这是一个nodejs项目,由于项目的紧急性已移至jxcore。 Please let me know if there is a way to handle it even from code level. 请让我知道,即使在代码级别上也有一种方法可以处理它。

Actually it's similar to a single Node.JS instance. 实际上,它类似于单个Node.JS实例。 You have same tools and options for handling the errors. 您具有处理错误的相同工具和选项。

Besides, JXcore thread warns the task queue when it catches an unexpected exception on the JS land (Task queue stops sending the requests back to this instance) then safely restarts the particular thread. 此外,当JXcore线程在JS平台上捕获到意外异常时(任务队列停止将请求发送回此实例),它会警告任务队列,然后安全地重新启动特定线程。 You may listen to 'uncaught exception', 'restart' events for the thread and manage a softer restart. 您可以侦听线程的“未捕获的异常”,“重新启动”事件,并管理更软的重新启动。

process.on('restart', res_cb, exit_code){
  // thread needs a restart (due to unhandled exception, IO, hardware etc..)
  // prepare your app for this thread's restart
  // call res_cb(exit_code) for restart. 
});

Note: JXcore expects the application is up and running at least for 5 seconds before restarting any thread. 注意:在重新启动任何线程之前,JXcore希望应用程序已启动并运行至少5秒钟。 Perhaps this limitation protects the application from looping thread restarts. 也许此限制可以保护应用程序免受线程重新启动的影响。

You may start your application using 'jx monitor' it supports multi thread and reloads the crashed processes. 您可以使用“ jx monitor”启动它的应用程序,它支持多线程并重新加载崩溃的进程。

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

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