Running your Node & Express apps forever, no matter what, with Systemd and PM2

added by bpwndaddy
6/26/2015 3:43:07 PM

1 Kicks, 477 Views

Running your Node & Express apps on your machine is easy. However, once you put them in production there are some new problems. What if the app crashes? What if the server restarts? What if some other failure happens? We’ve already talked about deploying on Ubuntu and CentOS but today we are going to go a little bit more specific. You need your apps to be running forever, no matter what happens. Unfortunately applications crash in unexpected ways and servers restart due to bugs or power or hardware failures. In all cases, you need to ensure that your app can return to operating normally, all by itself. You don’t want to wake up in the middle of the night or to cut your vacation short because your web app stopped working. An application that automatically keeps itself always running, even in the events of bugs or system restarts, gives you peace of mind and allows you to investigate the problem when you find it convenient, instead at 4 in the morning.