Production process manager for Node.JS applications with a built-in load balancer.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive command-line interface providing 68 commands for process management, monitoring, configuration, and system integration. PM2's CLI provides both simple operations and advanced features for production environments.
PM2 provides multiple CLI executables for different use cases:
# Main CLI - Full feature set
pm2 <command> [options]
# Development CLI - Enhanced debugging
pm2-dev <script> [options]
# Container runtime - Optimized for Docker
pm2-docker <script|config> [options]
pm2-runtime <script|config> [options]Essential commands for managing application processes.
# Start application with automatic name detection
pm2 start <script>
# Start with custom name
pm2 start <script> --name <app_name>
# Start in cluster mode with all CPU cores
pm2 start <script> -i max
# Start with specific number of instances
pm2 start <script> -i <number>
# Start from ecosystem file
pm2 start ecosystem.config.js
# Start with environment
pm2 start <script> --env production
# Start with custom options
pm2 start <script> --watch --ignore-watch="node_modules"Usage Examples:
# Start simple application
pm2 start app.js
# Start cluster application
pm2 start server.js --name "web-server" -i max
# Start with environment variables
pm2 start api.js --name "api" --env NODE_ENV=production --env PORT=3000
# Start from ecosystem configuration
pm2 start ecosystem.config.js --env production
# Start with file watching
pm2 start dev-server.js --watch --ignore-watch="logs"# Stop specific application
pm2 stop <name|id>
# Stop all applications
pm2 stop all
# Stop multiple applications
pm2 stop app1 app2 app3Usage Examples:
pm2 stop my-app
pm2 stop 0
pm2 stop all# Restart specific application
pm2 restart <name|id>
# Restart all applications
pm2 restart all
# Restart with environment update
pm2 restart <name|id> --update-envUsage Examples:
pm2 restart my-app
pm2 restart all --update-env# Zero-downtime reload (cluster mode only)
pm2 reload <name|id>
# Reload all cluster applications
pm2 reload all
# Reload with environment update
pm2 reload <name|id> --update-envUsage Examples:
pm2 reload web-server
pm2 reload all --update-env# Delete specific application
pm2 delete <name|id>
# Delete all applications
pm2 delete all
# Delete multiple applications
pm2 delete app1 app2Usage Examples:
pm2 delete old-app
pm2 delete 0 1 2
pm2 delete all# Scale application to specific number of instances
pm2 scale <name> <number>
# Scale to maximum CPU cores
pm2 scale <name> maxUsage Examples:
pm2 scale web-app 4
pm2 scale api maxCommands for retrieving process information and status.
# List all processes (table format)
pm2 list
pm2 ls
pm2 ps
pm2 status
# Simple list format
pm2 slist
# JSON format
pm2 jlist
# Pretty formatted list
pm2 prettylist# Describe specific process
pm2 describe <name|id>
pm2 desc <name|id>
pm2 info <name|id>
pm2 show <name|id>
# Get process ID
pm2 id <name>
# Get process PID
pm2 pid [app_name]Usage Examples:
pm2 describe my-app
pm2 pid web-server
pm2 id api-serviceReal-time monitoring and log management commands.
# Launch monitoring interface
pm2 monit
pm2 imonit
# Launch dashboard
pm2 dashboard
# System monitoring
pm2 sysmonit# Stream logs from all processes
pm2 logs
# Stream logs from specific process
pm2 logs <name|id>
# Stream logs with timestamp
pm2 logs --timestamp
# Stream specific number of lines
pm2 logs --lines <number>
# Flush all logs
pm2 flush
# Reload/rotate logs
pm2 reloadLogs
# Setup log rotation
pm2 logrotateUsage Examples:
pm2 logs my-app --lines 100
pm2 logs --timestamp
pm2 flush allCommands for managing PM2 configuration and settings.
# Get all configuration
pm2 conf
# Get specific configuration value
pm2 get <key>
# Set configuration value
pm2 set <key> <value>
# Set multiple values
pm2 multiset <values>
# Remove configuration value
pm2 unset <key>Usage Examples:
pm2 get pm2_home
pm2 set log-date-format "YYYY-MM-DD HH:mm:ss"
pm2 multiset "instances=max exec-mode=cluster"
pm2 unset log-date-format# Save current process list
pm2 dump
# Restore saved processes
pm2 resurrect
# Clear saved process list
pm2 cleardump
# Reset process counters
pm2 reset <name|id|all>Usage Examples:
pm2 dump
pm2 resurrect
pm2 reset my-appCommands for system-level operations and daemon management.
# Kill PM2 daemon and all processes
pm2 kill
# Test daemon connection
pm2 ping
# Update PM2 daemon
pm2 update
pm2 updatePM2# Generate startup script
pm2 startup [platform]
# Remove startup script
pm2 unstartup [platform]
# Auto-detect platform and generate startup
pm2 startupUsage Examples:
pm2 startup systemd
pm2 startup ubuntu
pm2 unstartupCommands for installing and managing PM2 modules.
# Install module
pm2 install <module_name>
# Install from Git URL
pm2 install <git_url>
# Uninstall module
pm2 uninstall <module_name>
# Update module
pm2 module:update <module_name>
# Generate module template
pm2 module:generate [app_name]
# Package module
pm2 package [target]
# Publish module
pm2 publish [folder]Usage Examples:
pm2 install pm2-logrotate
pm2 install git+https://github.com/username/pm2-module.git
pm2 uninstall pm2-server-monit
pm2 module:update pm2-logrotateCommands for development, debugging, and performance analysis.
# Start in development mode with auto-restart
pm2-dev <script>
# Development mode with options
pm2-dev <script> --watch --ignore-watch="node_modules"# Inspect process for debugging
pm2 inspect <name>
# CPU profiling
pm2 profile:cpu [time]
# Memory profiling
pm2 profile:mem [time]
# Attach to process
pm2 attach <pm_id> [separator]
# Send line to process stdin
pm2 send <pm_id> <line>
# Trigger custom action
pm2 trigger <id|name|namespace|all> <action> [params]
# Send signal to process
pm2 sendSignal <signal> <pm2_id|name>Usage Examples:
pm2 inspect my-app
pm2 profile:cpu 30
pm2 profile:mem
pm2 trigger my-app graceful-shutdown
pm2 sendSignal SIGUSR1 my-app# Show process environment
pm2 env <id>
# Get process environment variables
pm2 env <name|id>Commands for integrating with PM2+ cloud monitoring service.
# Link to PM2+
pm2 link [secret] [public] [name]
# Unlink from PM2+
pm2 unlink
# Login to PM2+
pm2 login
# Logout from PM2+
pm2 logout
# PM2+ operations
pm2 plus [command] [option]
# Open PM2+ dashboard
pm2 open
# Monitor process
pm2 monitor [name]
# Unmonitor process
pm2 unmonitor [name]Usage Examples:
pm2 link abc123 def456 my-server
pm2 unlink
pm2 openAdditional utility commands for various operations.
# Serve current directory
pm2 serve
# Serve specific directory and port
pm2 serve <path> [port]
# Serve with options
pm2 serve <path> <port> --spaUsage Examples:
pm2 serve ./public 8080
pm2 serve ./dist 3000 --spa# Deploy application
pm2 deploy <file|environment>
# Pull repository changes
pm2 pull <name> [commit_id]
# Navigate version control
pm2 forward <name>
pm2 backward <name>
# Deep update process
pm2 deepUpdate# Generate ecosystem file
pm2 ecosystem [mode]
# Create ecosystem template
pm2 create
# Start from ecosystem with specific environment
pm2 start ecosystem.config.js --env productionUsage Examples:
pm2 ecosystem simple
pm2 ecosystem
pm2 create# Show usage examples
pm2 examples
# Generate diagnostic report
pm2 report
# Auto-install dependencies
pm2 autoinstallPM2 commands support various options that can be combined:
--name <name> # Process name
--namespace <namespace> # Process namespace
-i, --instances <number> # Number of instances
--exec-mode <mode> # Execution mode (fork|cluster)
--watch # Enable file watching
--ignore-watch <pattern> # Ignore watch patterns
--max-memory-restart <mem> # Memory restart threshold
--env <environment> # Environment to use
--cwd <path> # Working directory
--log <path> # Log file path
--output <path> # Stdout log file
--error <path> # Stderr log file
--pid <path> # PID file path
--merge-logs # Merge cluster logs
--log-date-format <fmt> # Log timestamp format
--restart-delay <delay> # Restart delay in ms
--time # Prefix logs with time
--no-autorestart # Disable auto restart
--cron <pattern> # Cron restart pattern
--no-daemon # Do not run in daemon modepm2 start app.js \
--name "my-app" \
--instances max \
--exec-mode cluster \
--watch \
--ignore-watch "node_modules" \
--max-memory-restart 1G \
--env production \
--log-date-format "YYYY-MM-DD HH:mm:ss Z" \
--merge-logsPM2 CLI commands return standard exit codes:
0 - Success1 - General error2 - Connection error3 - Process not found4 - Configuration errorInstall with Tessl CLI
npx tessl i tessl/npm-pm2