Hey dear Vimmers!
Currently (May 4th, 2021) Workflow Integration Desktop uses pkg to turn node.js processes into .exe files. Sadly, pkg has a bug that causes it to break when packaging something the uses pm2, due to some bug with bash files. This weird fork removes the usage of the library that uses the bash file, so pkg doesn't break. This means we need to import our own version of pm2 and not the original one. So, this package is eventually uploaded to npm as @getvim/pm2. Why does this library exist?
This change removes the usage of the package pm2-deploy - it will completely break "pm2 deploy" CLI, but we currently don't use it.
How to update the package in npm?
This package does not have a build process at all, so you just need to
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 8.X.
$ npm install pm2 -g
Or if you don't have Node.js installed:
wget -qO- https://getpm2.com/install.sh | bash
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.
Once applications are started you can manage them easily:
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
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
-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:
With the drop-in replacement command for
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" ]
Terminal Based Monitoring
Monitor all processes launched straight from the command line:
$ pm2 monit
To consult logs just type the command:
$ pm2 logs
Standard, Raw, JSON and formated output are available.
$ 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
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
# Generate Startup Script $ pm2 startup # Freeze your process list across server restart $ pm2 save # Remove Startup Script $ pm2 unstartup
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):
# Install latest PM2 version $ npm install pm2@latest -g # Save process list, exit old PM2 & restore all processes $ pm2 update
PM2 updates are seamless
If you manage your apps with PM2, PM2+ makes it easy to monitor and manage apps across servers.
Feel free to try it:
Thanks in advance and we hope that you like PM2!
PM2 is made available under the terms of the GNU Affero General Public License 3.0 (AGPL 3.0). For other licenses contact us.