Unitech/pm2


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

http://pm2.keymetrics.io

License: Other

Language: JavaScript

Keywords: deploy, forever, load-balancer, manager, monitoring, node, nodejs, pm2, process, process-manager, production, startup-script



pm2 logo

P(rocess) M(anager) 2
Runtime Edition

npm version node version Build Status


PM2 is a production 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 to facilitate common system admin 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

PM2 Modules

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

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

PM2+ Monitoring

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

If you manage your NodeJS app 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!

More about 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.

GA

Project Statistics

Sourcerank 19
Repository Size 11.6 MB
Stars 30,071
Forks 2,011
Watchers 710
Open issues 752
Dependencies 37
Contributors 226
Tags 119
Created
Last updated
Last pushed

Top Contributors See all

Alexandre Strzelewicz Joni Shkurti vmarchaud Vincent Vallet Antoine Bluchet Jun Mili Juan Alex Kocharin Leo Zhou Robin Monnier Jimi M Aymeric Lavit d'Hautefort Dimitri Jorge Dan Dascalescu Edwin Chiu Xu Jingxin Nathanaël Lécaudé Rasmus Porsager Nathan Rugg Peter Dave Hello

Packages Referencing this Repo

@magiclab/pm2
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 3.5.1 - Published - 30.1K stars
pm2-notrack
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 3.5.1 - Published - 30.1K stars
@cutii/pm2
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 2.9.1 - Published - 30.1K stars
@kanreisa/pm2
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 2.6.1 - Updated - 30.1K stars
@octoblu/pm2
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 2.6.2 - Updated - 30.1K stars
pm2-jhonny
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 2.0.12 - Updated - 30.1K stars
pm2
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 3.5.1 - Updated - 30.1K stars
pm2-fix
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 2.9.6 - Updated - 30.1K stars
pm2.5
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 0.0.128 - Updated - 30.1K stars
pm2-plus
Production process manager for Node.JS applications with a built-in load balancer.
Latest release 0.0.1 - Published - 30.1K stars

Recent Tags See all

4.0.0-beta-4 May 21, 2019
4.0.0-beta-3 May 19, 2019
4.0.0-beta-1 May 19, 2019
4.0.0-beta-2 April 08, 2019
3.5.0 April 08, 2019
3.4.1 March 26, 2019
3.4.0 March 08, 2019
3.3.1 February 18, 2019
3.3.0 February 14, 2019
3.2.9 January 17, 2019
3.2.7 January 09, 2019
3.2.5 January 09, 2019
3.2.4 December 19, 2018
3.2.3 December 05, 2018
3.2.2 October 05, 2018

Interesting Forks See all

keymetrics/pm2
Modern CLI process manager for Node apps with a builtin load-balancer
Updated - 7 stars
alsotang/PM2
Production process manager (mainly) for Node.JS apps with advanced features. Perfectly designed f...
Other - Updated - 3 stars - 3 forks
Wiredcraft/pm2
The modern CLI process manager for Node apps with native clusterization
JavaScript - MIT - Updated - 1 stars
netcon-source/pm2
The next generation CLI process manager for Node.js with native clusterization
JavaScript - MIT - Updated - 1 stars
webflow/pm2
Production process manager for Node.js apps with a built-in load balancer
JavaScript - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-04-08 11:15:55 UTC

Login to resync this repository