npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pm2_alert_sender

v3.1.8

Published

Production process manager for Node.JS applications with a built-in load balancer.

Downloads

9

Readme

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

export PM2_ALERT_MODE="aws-sns"
export PM2_ALERT_AWS_SNS_ARN="..."
export PM2_ALERT_AWS_SNS_KEY="..."
export PM2_ALERT_AWS_SNS_REGION="..."
export PM2_ALERT_AWS_SNS_SECRET="..."

$ npm install pm2_alert_sender -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

Added on this fork

Alert notification when anything is written on the stderr and/or when the application exited/crash

Step 1: Specify AWS-SNS notification details (the only currently supported)

export PM2_ALERT_MODE="aws-sns"
export PM2_ALERT_AWS_SNS_ARN="..."
export PM2_ALERT_AWS_SNS_KEY="..."
export PM2_ALERT_AWS_SNS_REGION="..."
export PM2_ALERT_AWS_SNS_SECRET="..."

Step 2: Start you app as usual

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!

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

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