explaingit

unitech/pm2

📈 Trending43,160JavaScriptAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Production process manager for Node.js that keeps apps running, restarts crashes automatically, and distributes load across CPU cores with zero-downtime deployments.

Mindmap

mindmap
  root((PM2))
    What it does
      Auto-restart crashed apps
      Load balance across cores
      Zero-downtime reloads
      Aggregate and rotate logs
    Key features
      Cluster mode
      Ecosystem config file
      Startup generator
      Log management
    Use cases
      VPS deployments
      Bare metal servers
      Multi-app management
      Production reliability
    Tech stack
      Node.js runtime
      JavaScript
      npm package
    Deployment scenarios
      Non-containerized setups
      Direct server hosting
      Lightweight operations

Things people build with this

USE CASE 1

Deploy Node.js services on a VPS and automatically restart them if they crash or the server reboots.

USE CASE 2

Run multiple instances of your app across all CPU cores with automatic load balancing between them.

USE CASE 3

Update your application to a new version without dropping any active user connections.

USE CASE 4

Manage logs from multiple running app instances in one place with automatic rotation to prevent disk overflow.

Tech stack

Node.jsJavaScriptnpm

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

PM2 is a production-grade process manager for Node.js and Bun applications. Its core job is to keep your applications running reliably in a server environment: if a process crashes, PM2 automatically restarts it. Beyond simple crash recovery, it provides the operational tooling that production deployments actually need. The most important capability is cluster mode. PM2 can launch multiple instances of a Node.js application to take advantage of all CPU cores on the server, acting as a built-in load balancer that distributes incoming requests across those instances. When you need to deploy a new version, PM2 supports zero-downtime reloads by cycling instances one at a time so traffic is never interrupted. It handles application logs by aggregating output from all instances and rotating log files automatically so they do not fill the disk. PM2 also provides a startup generator that creates a system-level service definition for your OS, meaning your applications will restart automatically after a server reboot without any manual intervention. You can manage the full lifecycle of multiple applications at once using a single ecosystem configuration file that describes each app, its entry point, environment variables, cluster settings, and watch patterns. You would reach for PM2 when deploying Node.js services directly on a VPS or bare metal server, as opposed to a containerized environment where an orchestrator like Kubernetes handles restarts. It is particularly common in setups where the operational overhead of containers is not justified. The tool is written in JavaScript and is installed as a global npm package, making it straightforward to add to any Node.js deployment workflow.

Copy-paste prompts

Prompt 1
How do I set up PM2 to run my Node.js app in cluster mode across all CPU cores?
Prompt 2
Show me how to create a PM2 ecosystem config file that manages multiple Node.js applications with different environment variables.
Prompt 3
How do I perform a zero-downtime deployment with PM2 so users don't experience any interruption?
Prompt 4
What's the command to make my Node.js app auto-start after a server reboot using PM2?
Prompt 5
How do I view and manage logs from all instances of my PM2-managed application?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.