aerial photography of water beside forest during golden hour
General

Install PM2 in AWS LightSail, EC2

Install PM2 globally. This is the first step. Execute below commands in AWS terminal.

sudo npm install pm2@latest -g

Make PM2 run during startup. This will daemonize pm2 and initialize it on system reboots. This step is very important. This will automatically start pm2 in case we restart our server instance.

pm2 startup

PM2 commands

PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/

Computer engineer interested in programming, electronics, application architecture, data visualization, automation and performance optimization.

Leave a Reply