🛠️
Utility2M+/wkAGPL-3.0

pm2

PM2 is a production process manager for Node.js applications that provides process monitoring, automatic restarts, load balancing, log management, and zero-down

Installation

npm
npm install -g pm2
yarn
yarn add -g pm2
pnpm
pnpm add -g pm2

Import

ESM
// Used as CLI: pm2 start app.js

Quick Example

usage
// Start application:
// pm2 start app.js -i max --name my-app

// ecosystem.config.js
module.exports = {
  apps: [{
    name: 'api',
    script: 'dist/server.js',
    instances: 'max',
    exec_mode: 'cluster',
    env_production: { NODE_ENV: 'production' },
  }],
};

About pm2

PM2 is a production process manager for Node.js applications that provides process monitoring, automatic restarts, load balancing, log management, and zero-downtime deployments. PM2 runs Node.js applications as background daemons, automatically restarting them if they crash and providing real-time monitoring of CPU usage, memory consumption, request count, and uptime through both CLI output and a web-based dashboard. The cluster mode leverages Node.js's cluster module to spawn multiple application instances across all available CPU cores, with PM2 handling load balancing and worker management transparently. PM2 supports ecosystem files (ecosystem.config.js) for defining multiple application configurations with environment-specific settings, startup scripts that configure PM2 to launch applications on system boot, and a deployment system for pushing code to remote servers. The log management system handles log rotation, merges output from clustered instances, and supports structured JSON logging. PM2 integrates with monitoring services through PM2 Plus (formerly Keymetrics) for remote monitoring, alerting, and profiling. PM2 is the most widely used production process manager for Node.js, deployed across thousands of production servers worldwide.

Quick Facts

Packagepm2
CategoryUtility
Weekly Downloads2M+
LicenseAGPL-3.0
Installnpm install -g pm2

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.