Hello friends,
I've created another cheatsheet, it's for pm2, which is actually my personal notes like the other articles. It could be helpful for you too.
What's PM2
PM2, or Process Manager 2, is a versatile and powerful process manager for Node.js applications. It's designed to simplify the deployment, management, and monitoring of Node.js applications in production environments.
PM2 comes with a range of features:
Process Management
Monitoring
Logging
Cluster Mode
Startup Script Generation
Environment and Configuration
Version Management
Security
Update Management
Global CLI
I personally utilize it primarily for managing processes and logging, allowing you to start, stop, and automatically restart Node.js processes.
Here's a list of commonly used PM2 commands along with examples:
- Start a Node.js application with PM2:
pm2 start app.js
- Start a NextJs application with a specific name:
pm2 start npm --name app-name -- start
- List all PM2 processes:
pm2 ls
- Show detailed information about a specific process:
pm2 show your-app-name
- View real-time logs of a specific process:
pm2 logs your-app-name
- Monitor system resources for all PM2 processes:
pm2 monit
-Stop a PM2 process:
pm2 stop your-app-name
- Restart a PM2 process:
pm2 restart your-app-name
- Delete a PM2 process:
pm2 delete your-app-name
- Reload a PM2 process (restarting without downtime):
pm2 reload your-app-name
- Save the list of PM2 processes for automatic startup:
pm2 save
- Startup PM2 on system boot:
pm2 startup
- View detailed status of all PM2 processes:
pm2 status
- Clear logs for a specific process:
pm2 flush your-app-name
These commands should cover most of the common tasks you need to perform when working with PM2. For more detailed information, you can always refer to the official PM2 documentation.
Also if you're looking to deploy NextJS Website From Scratch (with Ubuntu, NGINX and pm2) these videos would be helpful:
Top comments (0)