A Typescript version of PM2 4.5.0
P(rocess)
M(anager)
2
Runtime Edition
Don't use for your production app. Use PM2 instead
A process manager for Node.js applications.
Starting an application in production mode is as easy as:
$ pm2t start app.js
Works on Linux (stable) & macOS (stable) & Windows (stable). All Node.js versions are supported starting Node.js 8.X.
Installing PM2t
With NPM:
$ npm install pm2t -g
Start an application
You can start any application (Node.js, Python, Ruby, binaries in $PATH...) like that:
$ pm2t start app.js
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:
$ pm2t list
Managing apps is straightforward:
$ pm2t stop <app_name|namespace|id|'all'|json_conf>
$ pm2t restart <app_name|namespace|id|'all'|json_conf>
$ pm2t delete <app_name|namespace|id|'all'|json_conf>
To have more details on a specific application:
$ pm2t describe <id|app_name>
To monitor logs, custom metrics, application information:
$ pm2t 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).
Starting a Node.js application in cluster mode that will leverage all CPUs available:
$ pm2t 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:
$ pm2t 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
Terminal Based Monitoring
Monitor all processes launched straight from the command line:
$ pm2t monit
Log Management
To consult logs just type the command:
$ pm2t logs
Standard, Raw, JSON and formated output are available.
Examples:
$ pm2t logs APP-NAME
$ pm2t logs --json
$ pm2t logs --format
$ pm2t flush
$ pm2t reloadLogs
More about log management
Startup Scripts 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
$ pm2t startup
$ pm2t save
$ pm2t unstartup
More about Startup Scripts Generation
PM2 Modules
PM2 embeds a simple and powerful module system. Installing a module is straightforward:
$ pm2t 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
$ npm install pm2t@latest -g
$ pm2t update
Contributors
License