Anytime you run a program in your computer, it can fail for many reasons: maybe a server that it depends on is turned off or, even worst, an unhandled exception can tear down the running process. That's terrible for production applications as you leave your users without the server until you notice that it is not working.
This is where the process manager comes in, you can run your code behind a process manager and it will ensure that the process is always running. If something fails and crashes the program, the process manager will reset the entire application automatically.
There are two popular process managers for Node:
pm2, both work in a similar way; however,
pm2 seems to be more popular and provides more utility tools than ever. For this reason, we will use
pm2 for the stack.
Ubuntu comes with an integrated process manager known as Upstart. You can use the operative system process manager; however,
pm2 is focused on node applications, it allows you to run...