

To do this, navigate to the application folder in the terminal. Running the Application with PM2 The first step is to start the application using PM2. Using PM2 to Start a Node.js Application on Boot

The -g means that the package will be installed globally on the Pi. The PM2 CLI can be installed using npm by running the following in your terminal: npm install pm2 -g It has great documentation and is quick to get started with, which is why I’ve chosen to use it for a number of my applications. PM2 is a popular process manager that offers all of the features above and then some. This includes things like startup scripts, deployment management, logging, monitoring, hot reloading, and more.

Process managers let you control the lifecycle of your application by providing a means to manage common tasks needed to keep your application running. PM2, which stands for Process Manager 2, is a process manager for Node.js applications. While doable, this step can be automated by configuring the application to run when the Pi boots by using a process manager called PM2. What happens when you need to reboot the Pi or if it temporarily loses power though? You have to manually go through the steps above again to get your application running.
