PM2

Process manager for Node.js

IMPORTANT COMMANDS

pm2 start –name server_name –watch

server name = Your prefer server name
watch flag to reflect code update

pm2 status

show the server status

pm2 restart server_name or ID

restart a single process, check the status for name or ID.

pm2 restart all

restart all process

pm2 logs server_name or ID –line 20

display log 20 lines to check any error occurs

pm2 show server_name or ID

display process details. check exec cwd, scrpit path

I use PM2 for handling my website contact form email server. 

I got 500 error after restarted all PM2 process. 

To solve,

  • updated node version 8 > 20 (!!), 
  • reinstall PM2 and other node modules (actually I deleted all modules once and reinstall all)
  • use .env for credential information such as SMTP user and key, so make sure .env info is reflected to PM2 through server code.
  • And since update node and PM2, flush all old setting to start all the  PM2 processes.

Leave a Reply

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