Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pm2

> DevOps
Open source

Node.js/Bun Production Process Manager with a built-in Load Balancer.

43.3K stars0 likes8 views
WebsiteGitHub

About

Node.js/Bun Production Process Manager with a built-in Load Balancer.

PM2 is a production process manager for Node.js/Bun applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.

Starting an application in production mode is as easy as:

bash
$ pm2 start app.js

PM2 is battle-tested by a comprehensive test suite.

Official website: https://pm2.keymetrics.io/

Works on Linux, macOS, and Windows. Supports Node.js 18+ and Bun 1+.

Installing PM2

With NPM

bash
$ npm install pm2 -g

With Bun

bash
$ bun install pm2 -g

If you only have Bun installed (no Node.js), symlink node to bun so PM2's #!/usr/bin/env node shebang resolves to Bun's node-compatibility runtime:

bash
$ sudo ln -s $(which bun) /usr/local/bin/node

You can install Node.js easily with NVM or FNM or install Bun with curl -fsSL https://bun.sh/install | bash

Start an application

You can start any application (Node.js, Bun, and also Python, Ruby, binaries in $PATH...) like that:

bash
$ pm2 start app.js
$ pm2 start app.ts
$ pm2 start app.py

Your app is now daemonized, monitored and kept alive forever.

Managing Applications

Once applications are started you can manage them easily:

To list all running applications:

bash
$ pm2 list

Managing apps is straightforward:

bash
$ pm2 stop     <app_name|namespace|id|'all'|json_conf>
$ pm2 restart  <app_name|namespace|id|'all'|json_conf>
$ pm2 delete   <app_name|namespace|id|'all'|json_conf>

To have more details on a specific application:

bash
$ pm2 describe <id|app_name>

To monitor logs, custom metrics, application information:

bash
$ pm2 monit

More about Process Management

Cluster Mode: Node.js Load Balancing & Zero Downtime Reload

Cluster mode starts multiple Node.js processes and load-balances HTTP/TCP/UDP queries between them. This significantly increases throughput on multi-core machines and improves reliability (faster socket re-balancing in case of unhandled errors).

Starting a Node.js application in cluster mode that will leverage all CPUs available:

bash
$ pm2 start api.js -i <processes>

<processes> can be 'max', -1 (all cpu minus 1) or a specified number of instances to start.

Zero Downtime Reload

Hot Reload allows you to update an application without any downtime:

bash
$ pm2 reload all

More information about how PM2 makes clustering easy

Container Support

With the drop-in replacement command for node, called pm2-runtime, run your Node.js application in a hardened production environment. Using it is seamless:

dockerfile
RUN npm install pm2 -g
CMD [ "pm2-runtime", "npm", "--", "start" ]

Read More about the dedicated integration

Terminal Based Monitoring

Monitor all processes launched straight from the command line:

bash
$ pm2 monit

Log Management

To consult logs just type the command:

bash
$ pm2 logs

Standard, Raw, JSON and formatted output are available.

Examples:

bash
$ pm2 logs APP-NAME       # Display APP-NAME logs
$ pm2 logs --json         # JSON output
$ pm2 logs --format       # Formatted output

$ pm2 flush               # Flush all logs
$ pm2 reloadLogs          # Reload all logs

To enable log rotation install the following module

bash
$ pm2 install pm2-logrotate

More about log management

Startup Scripts Generation

PM2 can generate and configure a Startup Script to keep PM2 and your processes alive at every server restart.

Init Systems Supported: systemd, upstart, systemv, openrc, launchd, rcd, rcd-openbsd, smf

bash
# Generate Startup Script
$ pm2 startup

# Freeze your process list across server restart
$ pm2 save

# Remove Startup Script
$ pm2 unstartup

More about Startup Scripts Generation

Updating PM2

bash
# Install latest PM2 version
$ npm install pm2@latest -g
# Save process list, exit old PM2 & restore all processes
$ pm2 update

PM2 updates are seamless

PM2+ Monitoring

If you manage your apps with PM2, PM2+ makes it easy to monitor and manage apps across servers.

Feel free to try it:

Discover the monitoring dashboard for PM2

Thanks in advance and we hope that you like PM2!

CHANGELOG

CHANGELOG

Contributors

Contributors

License

PM2 is made available under the terms of the GNU Affero General Public License 3.0 (AGPL 3.0). For other licenses contact us.

Issues· 1105 open

View all issuesOpen on GitHub
  • #5509

    pm2 reloadLogs fails for fork mode if only log_file is set but out_file and error_file are both NULL

    Updated Sep 26, 2026
  • #6162

    Bun fork container uses require(), so an ESM entry containing top-level await cannot start

    Updated Sep 21, 2026
  • #6074

    WMIC Related issue

    Updated Sep 12, 2026
  • #6158

    [email protected] has CVE

    Updated Sep 9, 2026
  • #5919

    PM2 Cluster Mode does not work with NODE_EXTRA_CA_CERTS certificates

    Updated Sep 9, 2026
  • #6150

    PM2 module installation should support other package managers

    Updated Sep 5, 2026
  • #6148

    pm2 serve: add e-book MIME types

    Updated Sep 1, 2026
  • #5187

    Add option to increase displayed log lines in pm2 monit

    Updated Aug 26, 2026
  • #5482

    "[PM2][ERROR] Process not found" even though process is running

    Updated Aug 11, 2026
  • #6134

    Error caught while calling pid usage

    Updated Aug 8, 2026

> Tags

JavaScriptcommand-linecommand-line-tooldeployload-balancer

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理