pm2
Production process manager for Node.JS applications with a built-in load balancer.
Last updated 16 days ago by tknew .
AGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pm2 -g
SYNC missed versions from official npm registry.

pm2 logo

P(rocess) M(anager) 2
Runtime Edition

npm version npm version Build Status


PM2 is a Production Runtime and Process Manager for Node.js applications with a built-in Load Balancer. It allows you to keep applications alive forever, to reload them without downtime and facilitate common Devops tasks.

Starting an application in production mode is as easy as:

$ pm2 start app.js

PM2 is constantly assailed by more than 1800 tests.

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

Works on Linux (stable) & macOS (stable) & Windows (stable). All Node.js versions are supported starting Node.js 4.X.

NPM

Installing PM2

$ npm install pm2 -g

npm is a builtin CLI when you install Node.js - Installing Node.js with NVM

Start an application

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

$ pm2 start app.js

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

More about Process Management

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:

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

Read More about the dedicated integration

Managing Applications

Once applications are started you can manage them easily:

Process listing

To list all running applications:

$ pm2 list

Managing apps is straightforward:

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

To have more details on a specific application:

$ pm2 describe <id|app_name>

To monitor logs, custom metrics, application information:

$ pm2 monit

More about Application Management

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

The Cluster mode is a special mode when starting a Node.js application, it starts multiple processes and load-balance HTTP/TCP/UDP queries between them. This increase overall performance (by a factor of x10 on 16 cores machines) and reliability (faster socket re-balancing in case of unhandled errors).

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

$ 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 to update an application without any downtime:

$ pm2 reload all

Seamlessly supported by all major Node.js frameworks and any Node.js applications without any code change:

Framework supported

More informations about how PM2 make clustering easy

Terminal Based Monitoring

Monit

Monitor all processes launched straight from the command line:

$ pm2 monit

Log Management

To consult logs just type the command:

$ pm2 logs

Standard, Raw, JSON and formated output are available.

Examples:

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

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

More about log management

Startup Hooks Generation

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

Init Systems Supported: systemd, upstart, launchd, rc.d

# Generate Startup Script
$ pm2 startup

# Freeze your process list across server restart
$ pm2 save

# Remove Startup Script
$ pm2 unstartup

More about Startup Hooks

Updating PM2

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

PM2 updates are seamless

Ready to Scale? Go further with PM2 Plus!



PM2 plus logo

PM2
Plus Edition

Once you scale you need to make sure that your application is running properly, without bugs, performance issues and without downtimes.

That's why we created PM2 Plus. It's a set of advanced features for both hardening the PM2 Runtime and monitoring applications in production.

With PM2 Plus you get:

  • A Real-time Monitoring Web Interface
  • Smart Exception Reporting
  • Production Profiling for Memory and CPU
  • PM2 Runtime High Availability Fallback

And much more like realtime logs, custom metrics, remote actions...

To start using PM2 Plus via CLI:

$ pm2 plus

Or go to the application and create an account:

To discover PM2 Plus Register Here

PM2 Plus Features

Visual Memory Snapshots:

https://raw.githubusercontent.com/Unitech/pm2/master/pres/memory-profiling.png

CPU FlameGraphs:

https://raw.githubusercontent.com/Unitech/pm2/master/pres/flamegraph.png

Multi Server Overview:

https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-ls-multi.png

To discover PM2 Plus Register Here

PM2 Plus: Expose Custom Metrics

To get more insights on how your application behave, plug custom metrics inside your code and monitor them with the pm2 monit command:

In your project install pm2-io-pm:

$ npm install @pm2/io --save

Then plug a custom metric:

const io = require('@pm2/io');

let counter = 1;

const latency = io.metric({
   name    : 'Counter',
   value   : function() {
     return counter;
   }
});

setInterval(() => {
  counter++;
}, 1000);

PM2 Plus: Module system

PM2 embeds a simple and powerful module system. Installing a module is straightforward:

$ pm2 install <module_name>

Here are some PM2 compatible modules (standalone Node.js applications managed by PM2):

pm2-logrotate automatically rotate logs and limit logs size
pm2-server-monit monitor the current server with more than 20+ metrics and 8 actions

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.

GA

Current Tags

  • 0.10.0-beta1                                ...           0.10.0-beta1 (4 years ago)
  • 0.10.0-beta10                                ...           0.10.0-beta10 (4 years ago)
  • 0.10.0-beta11                                ...           0.10.0-beta11 (4 years ago)
  • 0.10.0-beta12                                ...           0.10.0-beta12 (4 years ago)
  • 0.10.0-beta13                                ...           0.10.0-beta13 (4 years ago)
  • 0.10.0-beta14                                ...           0.10.0-beta14 (4 years ago)
  • 0.10.0-beta15                                ...           0.10.0-beta15 (4 years ago)
  • 0.10.0-beta16                                ...           0.10.0-beta16 (4 years ago)
  • 0.10.0-beta17                                ...           0.10.0-beta17 (4 years ago)
  • 0.10.0-beta18                                ...           0.10.0-beta18 (4 years ago)
  • 0.10.0-beta19                                ...           0.10.0-beta19 (4 years ago)
  • 0.10.0-beta2                                ...           0.10.0-beta2 (4 years ago)
  • 0.10.0-beta20                                ...           0.10.0-beta20 (4 years ago)
  • 0.10.0-beta21                                ...           0.10.0-beta21 (4 years ago)
  • 0.10.0-beta22                                ...           0.10.0-beta22 (4 years ago)
  • 0.10.0-beta23                                ...           0.10.0-beta23 (4 years ago)
  • 0.10.0-beta25                                ...           0.10.0-beta25 (4 years ago)
  • 0.10.0-beta4                                ...           0.10.0-beta4 (4 years ago)
  • 0.10.0-beta5                                ...           0.10.0-beta5 (4 years ago)
  • 0.10.0-beta6                                ...           0.10.0-beta6 (4 years ago)
  • 0.10.0-beta7                                ...           0.10.0-beta7 (4 years ago)
  • 0.10.0-beta8                                ...           0.10.0-beta8 (4 years ago)
  • 0.10.0-beta9                                ...           0.10.0-beta9 (4 years ago)
  • 3.2.2                                ...           latest (16 days ago)
  • 2.9.2-next                                ...           next (10 months ago)

227 Versions

  • 3.2.2                                ...           16 days ago
  • 3.2.1                                ...           18 days ago
  • 3.2.0                                ...           19 days ago
  • 3.1.3                                ...           a month ago
  • 3.1.2                                ...           a month ago
  • 3.1.1                                ...           a month ago
  • 3.1.0                                ...           a month ago
  • 3.0.4                                ...           2 months ago
  • 3.0.3                                ...           3 months ago
  • 3.0.2                                ...           3 months ago
  • 3.0.1                                ...           3 months ago
  • 3.0.0                                ...           4 months ago
  • 2.10.4                                ...           5 months ago
  • 2.10.3                                ...           6 months ago
  • 2.10.2                                ...           7 months ago
  • 2.10.1                                ...           8 months ago
  • 2.10.0                                ...           8 months ago
  • 2.9.3                                ...           9 months ago
  • 2.9.2                                ...           9 months ago
  • 2.9.2-next                                ...           10 months ago
  • 2.9.1                                ...           10 months ago
  • 2.9.0                                ...           10 months ago
  • 2.8.0-next                                ...           10 months ago
  • 2.8.0                                ...           a year ago
  • 2.7.2                                ...           a year ago
  • 2.7.1                                ...           a year ago
  • 2.7.0                                ...           a year ago
  • 2.6.1                                ...           a year ago
  • 2.6.0                                ...           a year ago
  • 2.5.0                                ...           a year ago
  • 2.5.0-beta1                                ...           a year ago
  • 2.4.6                                ...           a year ago
  • 2.4.5                                ...           2 years ago
  • 2.4.4                                ...           2 years ago
  • 2.4.3                                ...           2 years ago
  • 2.4.3-rc1                                ...           2 years ago
  • 2.4.2                                ...           2 years ago
  • 2.4.1                                ...           2 years ago
  • 2.4.1-beta5                                ...           2 years ago
  • 2.4.1-beta4                                ...           2 years ago
  • 2.4.1-beta3                                ...           2 years ago
  • 2.4.1-beta2                                ...           2 years ago
  • 2.4.1-beta1                                ...           2 years ago
  • 2.4.0                                ...           2 years ago
  • 2.4.0-beta5                                ...           2 years ago
  • 2.4.0-beta4                                ...           2 years ago
  • 2.4.0-beta3                                ...           2 years ago
  • 2.4.0-beta2                                ...           2 years ago
  • 2.4.0-beta1                                ...           2 years ago
  • 2.3.1-next                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.3.0-beta1                                ...           2 years ago
  • 2.2.3                                ...           2 years ago
  • 2.2.2                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.6                                ...           2 years ago
  • 2.1.5                                ...           2 years ago
  • 2.1.4                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.19                                ...           2 years ago
  • 2.0.18                                ...           2 years ago
  • 2.0.17                                ...           2 years ago
  • 2.0.16                                ...           2 years ago
  • 2.0.15                                ...           2 years ago
  • 2.0.14                                ...           2 years ago
  • 2.0.13                                ...           2 years ago
  • 2.0.12                                ...           2 years ago
  • 2.0.10                                ...           2 years ago
  • 2.0.9                                ...           2 years ago
  • 2.0.8                                ...           2 years ago
  • 2.0.7                                ...           2 years ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.15.10                                ...           3 years ago
  • 0.15.9                                ...           3 years ago
  • 0.15.8                                ...           3 years ago
  • 0.15.7                                ...           3 years ago
  • 0.15.6                                ...           3 years ago
  • 0.15.5                                ...           3 years ago
  • 0.15.4                                ...           3 years ago
  • 0.15.3                                ...           3 years ago
  • 0.15.2                                ...           3 years ago
  • 0.15.1                                ...           3 years ago
  • 0.15.0                                ...           3 years ago
  • 0.14.7                                ...           3 years ago
  • 0.14.6                                ...           3 years ago
  • 0.14.5                                ...           3 years ago
  • 0.14.4                                ...           3 years ago
  • 0.14.3                                ...           3 years ago
  • 0.14.2                                ...           3 years ago
  • 0.14.1                                ...           3 years ago
  • 0.14.0                                ...           3 years ago
  • 0.12.16                                ...           3 years ago
  • 0.12.15                                ...           3 years ago
  • 0.12.14                                ...           3 years ago
  • 0.12.13                                ...           3 years ago
  • 0.12.12                                ...           3 years ago
  • 0.12.11                                ...           4 years ago
  • 0.12.10                                ...           4 years ago
  • 0.12.9                                ...           4 years ago
  • 0.12.8                                ...           4 years ago
  • 0.12.7                                ...           4 years ago
  • 0.12.6                                ...           4 years ago
  • 0.12.5                                ...           4 years ago
  • 0.12.4                                ...           4 years ago
  • 0.12.3                                ...           4 years ago
  • 0.12.2                                ...           4 years ago
  • 0.12.1                                ...           4 years ago
  • 0.12.0                                ...           4 years ago
  • 0.11.1                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.11.0-beta1                                ...           4 years ago
  • 0.10.8                                ...           4 years ago
  • 0.10.7                                ...           4 years ago
  • 0.10.6                                ...           4 years ago
  • 0.10.5                                ...           4 years ago
  • 0.10.4                                ...           4 years ago
  • 0.10.3                                ...           4 years ago
  • 0.10.2                                ...           4 years ago
  • 0.10.1                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.10.0-beta25                                ...           4 years ago
  • 0.10.0-beta23                                ...           4 years ago
  • 0.10.0-beta22                                ...           4 years ago
  • 0.10.0-beta21                                ...           4 years ago
  • 0.10.0-beta20                                ...           4 years ago
  • 0.10.0-beta19                                ...           4 years ago
  • 0.10.0-beta18                                ...           4 years ago
  • 0.10.0-beta17                                ...           4 years ago
  • 0.10.0-beta16                                ...           4 years ago
  • 0.10.0-beta15                                ...           4 years ago
  • 0.10.0-beta14                                ...           4 years ago
  • 0.10.0-beta13                                ...           4 years ago
  • 0.10.0-beta12                                ...           4 years ago
  • 0.10.0-beta11                                ...           4 years ago
  • 0.10.0-beta10                                ...           4 years ago
  • 0.10.0-beta9                                ...           4 years ago
  • 0.10.0-beta8                                ...           4 years ago
  • 0.10.0-beta7                                ...           4 years ago
  • 0.10.0-beta6                                ...           4 years ago
  • 0.10.0-beta5                                ...           4 years ago
  • 0.10.0-beta4                                ...           4 years ago
  • 0.10.0-beta2                                ...           4 years ago
  • 0.10.0-beta1                                ...           4 years ago
  • 0.9.6                                ...           4 years ago
  • 0.9.5                                ...           4 years ago
  • 0.9.4                                ...           4 years ago
  • 0.9.3                                ...           4 years ago
  • 0.9.2                                ...           4 years ago
  • 0.9.1                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 0.8.15                                ...           4 years ago
  • 0.8.14                                ...           4 years ago
  • 0.8.13                                ...           4 years ago
  • 0.8.12                                ...           4 years ago
  • 0.8.11                                ...           4 years ago
  • 0.8.10                                ...           4 years ago
  • 0.8.9                                ...           4 years ago
  • 0.8.8                                ...           4 years ago
  • 0.8.7                                ...           4 years ago
  • 0.8.6                                ...           4 years ago
  • 0.8.5                                ...           4 years ago
  • 0.8.4                                ...           4 years ago
  • 0.8.3                                ...           4 years ago
  • 0.8.2                                ...           4 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.8                                ...           5 years ago
  • 0.7.7                                ...           5 years ago
  • 0.7.6                                ...           5 years ago
  • 0.7.5                                ...           5 years ago
  • 0.7.4                                ...           5 years ago
  • 0.7.3                                ...           5 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.15                                ...           5 years ago
  • 0.6.14                                ...           5 years ago
  • 0.6.13                                ...           5 years ago
  • 0.6.12                                ...           5 years ago
  • 0.6.11                                ...           5 years ago
  • 0.6.10                                ...           5 years ago
  • 0.6.9                                ...           5 years ago
  • 0.6.8                                ...           5 years ago
  • 0.6.7                                ...           5 years ago
  • 0.6.6                                ...           5 years ago
  • 0.6.5                                ...           5 years ago
  • 0.6.4                                ...           5 years ago
  • 0.6.3                                ...           5 years ago
  • 0.6.2                                ...           5 years ago
  • 0.5.7                                ...           5 years ago
  • 0.5.6                                ...           5 years ago
  • 0.5.5                                ...           5 years ago
  • 0.5.4                                ...           5 years ago
  • 0.5.3                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.1                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.14                                ...           5 years ago
  • 0.4.13                                ...           5 years ago
  • 0.4.12                                ...           5 years ago
  • 0.4.11                                ...           5 years ago
  • 0.4.10                                ...           5 years ago
  • 0.4.8                                ...           5 years ago
  • 0.4.7                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.4                                ...           5 years ago
  • 0.4.3                                ...           5 years ago
  • 0.4.2                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 7
This Week 7
This Month 12,155
Last Day 188
Last Week 5,088
Last Month 16,830
Dependencies (32)
Dev Dependencies (2)
Dependents (630)

Copyright 2014 - 2016 © taobao.org |