Skip to content
Advertisement

Auto restart or Proper Handling socket.io server on exception in linux

I’ved got my socket.io server running in the background. However, there are several situation where it died. What can I do to make my socket.io server auto restart whenever it dies or terminated.

This is how I started my node server

JavaScript

however the server thrown an exception and died.

JavaScript

This is my environment

JavaScript

and I believe my team is using this:

JavaScript

Advertisement

Answer

You can use pm2 to monitor logs, auto restart… etc. For example:

JavaScript

More about watch & restart.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement