Post/Code

HomeAboutUsesNow

PM2 Commands.

Here are some PM2 commands:

  • pm2 start ecosystem.config.js
  • pm2 stop all
  • pm2 delete all
  • pm2 show id-of-process
  • pm2 env 0
  • pm2 log
  • pm2 monit

When using dotenv with PM2 and Lerna, keep in mind that PM2 will be looking in your root for its environment variables, as such, you will need to set your .env variables in the root. This meant I need to update the naming I used in my services to things such as GATEWAY_PORT and DB_PORT as opposed to just PORT in the separate packages.

Transitioning to PM2 from a simple nodemon setup takes some getting used to and means you need to get comfortable with viewing and navigating output and error log files. You will find these in your user folder under .pm2/logs.