pm2 and forever command for beginnners

pm2 and forever command for beginnners

pm2 and forever is a tool to run the process at the background, many of the angular developers are using these tools nowadays in any linux/amazon ec2 machines for angular universal server side rendering(ssr) for seo and many other features.

 

Herewith I have listed the few mostly used commands:

pm2 commands:

pm2 start your_js_file (pm2 start local.js) in my case for angular universal run,

this build is created using the below commands,

npm run build:prod (or) yarn run build:prod 

and

npm run server (or) yarn run server

 

pm2 list: list down all the pm2 processes.

pm2 kill: to kill all the running pm2 processes

pm2 monit: to monitor the running processes

pm2 logs: to see the logs of the running pm2 processes.

pm2 start all: to start all the pm2 process

pm2 start your_pm2_process_name: to start the particular pm2 process.

pm2 stop your_pm2_process_name: to stop the particular process. pm2 kill can be used to stop all the running pm2 processes.

pm2 show your_pm2_process_name: to show the details about this particular pm2 process.

sudo cat /root/.pm2/pm2.log: to show the log details even when the pm2 is not started. (or getting stopped immediately after the start)

sudo cat /home/ec2-user/.pm2/logs/local-error-0.log:  Run this command often to know the errors happened behind pm2.

 

 

Forever commands:

forever local.js (runs directly)

forever show

forever start local.js (runs in daemon mode)

660 total views, 4 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.