Treat Nodejs application for when crash, the server restart alone

Asked

Viewed 143 times

2

I have a Nodejs application that when crashes with some error in the controller the server stops and says that it is waiting to fix the error in order to restart the application. How do I restart it again after some unexpected error?

  • Wouldn’t it be better if you put an Englishman in your process of the kind uncaughtException? So every exception not captured by a Try/catch block will be captured by Event Listener, your application will not break and you will not need to restart the whole process.

  • So, but the right one is to actually crash the server, so you fix the problem with the utmost urgency

1 answer

1


Ideally, while your project is being developed, you detect all the relevant exceptions to your system and treat them to prevent the process from dying from silly errors.

But, unexpected mistakes can happen in production. In order to keep your system on the air, you can use a process manager to monitor it. There are some done in Node even as the pm2 and were to review, and others like the supervisor.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.