• Stars
    star
    41,442
  • Rank 341 (Top 0.01 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 11 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

pm2 logo

P(rocess) M(anager) 2
Runtime Edition

Downloads per Month Downloads per Year npm 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.keymetrics.io/

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

Installing PM2

With NPM:

$ npm install pm2 -g

You can install Node.js easily with NVM or ASDF.

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.

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|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:

$ pm2 describe <id|app_name>

To monitor logs, custom metrics, application information:

$ pm2 monit

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

Framework supported

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

More informations about how PM2 make 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:

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

Read More about the dedicated integration

Host monitoring speedbar

PM2 allows to monitor your host/server vitals with a monitoring speedbar.

To enable host monitoring:

$ pm2 set pm2:sysmonit true
$ pm2 update

Framework supported

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

To enable log rotation install the following module

$ 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, 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 Scripts Generation

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

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

https://app.pm2.io/

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.

More Repositories

1

gridcontrol

Networked Process Manager to execute functions in a Computer Grid
JavaScript
577
star
2

angular-bridge

Link models easily via a REST interface between Mongoose/Node-Express/Angular.js
JavaScript
208
star
3

pm2-deploy

Deploy part of PM2
JavaScript
178
star
4

node-logman

Log client side/server side messages and monitor them with a realtime interface
CSS
113
star
5

pm2-interface

Deprecated
JavaScript
90
star
6

multissh

SSH into multiple machine to execute a command in parallel, with a convenient terminal UX
JavaScript
51
star
7

Skytoop

A Nice Desktop in Cloud with a filemanager and a lot of features ! Fork it ! Web2Py
JavaScript
30
star
8

cryptoengine

Monitor and verify transactions from a local or remote bitcoin deamon.
JavaScript
20
star
9

pm2-axon

JavaScript
19
star
10

pm2-axon-rpc

Modified version of visionmedia/axon-rpc
JavaScript
15
star
11

express-repl

Interact with express internal data (routes, settings...) with an auto reconnect remote repl
JavaScript
11
star
12

yeoman-jade-angularjs

Yeoman template with nice jade integration (Haml like)
JavaScript
10
star
13

scaleway-commander

Manage a fleet of scaleway servers
JavaScript
10
star
14

WebGL-solar-system

WebGL - Three.js v53 - Realistic solar system in WebGL
JavaScript
9
star
15

spiderlink

Simple, yet optimized application intercommunication within the same machine. Based on WS.
JavaScript
8
star
16

pm2-openstack

Nginx load balancing and hot edit + load monitoring and create VM triggers
7
star
17

gc-refresh-mode

Google Chrome & Emacs & File Save = Automatic Refresh. This plugin permits you to refresh AUTOMATICALLY google chrome when saving a file ! - Fell free to fork it and enhance it. It worth (I do not have enough time to maitain it) -
Python
6
star
18

pm2-dev

Development dashboard for pm2
JavaScript
6
star
19

ProjectManager

J2EE - Spring (MVC, Secutiry, Autowiring), Hibernate, PostgreSQL, ExtJS. Project manager
JavaScript
5
star
20

Web2Py-application-template

Application template for Web2Py including JS/CSS minification, logger...
JavaScript
5
star
21

Speak.js

Make your software speak, naturally
JavaScript
4
star
22

afflux-server.js

Standalone log server, that routes and send message logs to different db/bucket/table/realtime interface
JavaScript
4
star
23

InterBenchmark

Benchmarks script : Node.Js vs Ruby Rails vs Django vs WebPy vs J2EE-Spring vs Express vs Php - Nginx FastCgi Passenger Tomcat
Shell
3
star
24

coinvest

coinvest
JavaScript
3
star
25

youtube-to-mp3-UI

Your own youtubetomp3
JavaScript
3
star
26

micro-dot-files

dot files for low resources systems (.bashrc/.emacs.el/nodejs)
Shell
3
star
27

Empathy

Baby steps with Raspberry Pi & Node.js
JavaScript
3
star
28

Css-Sprite-AutoGen

Transform multiple images in one and gives css position - Avoid multiple request for each images - Web2Py application
JavaScript
2
star
29

test-repo

JavaScript
2
star
30

easy-voice

JavaScript
2
star
31

lensesly

lensesly
Ruby
2
star
32

companystats

JavaScript
2
star
33

GeonameLocal

GeonameLocal
Shell
2
star
34

Eschool

LMS
JavaScript
2
star
35

afflux-logger.js

Logger client for afflux server - namespaced and custom logger for logging specific events
JavaScript
2
star
36

high-summary

Retrieve title, image and summary of a web page
JavaScript
2
star
37

synapsis

JavaScript
2
star
38

Speak

Speak
JavaScript
2
star
39

node-v8tools

V8 profiler bindings
C++
2
star
40

Sputnik

Library to control Drone over 4G (Hybrid System) / Drone as API / Expose the world as an API
Python
2
star
41

Gsplitter

Gsplitter extension allows you to have a big preview of Google search results !
JavaScript
2
star
42

SoundcloudCommentsHider

Chrome extension - Automatically hide comments on Soundcloud.
JavaScript
1
star
43

nurse-api

Interface for seccomp-nurse
JavaScript
1
star
44

auto-ap

Shell
1
star
45

DeportedChat

JavaScript
1
star
46

.i3

C
1
star
47

storydata-htp

JavaScript
1
star
48

pm2-hub-rd

R&D on pub sub system
JavaScript
1
star
49

rails_snippets

Some rails snippets
1
star
50

Unification

Ruby
1
star
51

Quizzy

Quizzy
JavaScript
1
star
52

rails_template

rails new my_new_app -m rails_template/generate_template.rb
Ruby
1
star
53

carcass-auth-app

JavaScript
1
star
54

carcass-memoray

In memory storage with array.js
JavaScript
1
star
55

TAH-project

JavaScript
1
star
56

Monetify

Monetify
Ruby
1
star
57

mavlinkjs

JavaScript
1
star
58

release-test-check

JavaScript
1
star
59

Arduino_LoRa_SX12XX_Demo_Sensor-heltec-ab01

C
1
star
60

thinblog

Thin Wordpress Theme for Wordpress - Example : http://blog.hemca.fr
PHP
1
star
61

reach

1
star
62

jquery.heat-progressbar

Jquery plugin for drawing easily a progressbar with heat color
JavaScript
1
star
63

clem-remote

JavaScript
1
star
64

afflux-listener.js

JavaScript
1
star
65

Gamification

Ruby
1
star
66

OpenStreetMap

OpenStreetMap
JavaScript
1
star
67

AMNBS-boilerplate

Boilerplate/Structure App - Mongoose + Nodejs + Express + AngularJS + Boostrap + Compass
JavaScript
1
star
68

gc-refresh-mode-

Google Chrome & Emacs & File Save = Automatic Refresh. This plugin permits you to refresh AUTOMATICALLY google chrome when saving a file !
1
star
69

MDNotes

Live markdown editor with multiple accounts
JavaScript
1
star
70

youtube-download

JavaScript
1
star
71

afflux-express.js

Middlewares for Express to log access and errors to afflux-server.js
1
star