简体   繁体   中英

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

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. 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. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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