• Stars
    star
    530
  • Rank 83,660 (Top 2 %)
  • Language
    JavaScript
  • Created about 11 years ago
  • Updated almost 3 years ago

Reviews

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

Repository Details

A web based monitor for PM2

Deprecation warning

Since it's no longer possible to monitor pm2 running on multiple machines I'm not really working on pm2-web any more.

For an alternative, check out Guvnor - a process manager with support for multiple hosts, unix based permissions, a far more capable web interface and more.

pm2-web

Dependency Status devDependency Status Build Status Coverage Status

A web based monitor for PM2.

Screenshot of web monitor

Multiple hosts

With the release of 0.11 pm2 no longer uses TCP sockets for the event bus, instead using unix sockets. TCP sockets make monitoring hosts remotely possible so that functionality is currently broken.

Hopefully the pm2 team have a solution for this.

Prerequisites

For debugging to work, node-inspector must be installed and running on the same machine as pm2 (not necessarily the same as pm2-web).

To run

Install pm2-web:

$ npm install -g pm2-web

Then run:

$ pm2-web

Configuration

All configuration options are documented in the default configuration file.

pm2-web will load one of the following files if they exist (in order of preference)

  • A file specified by the --config /path/to/config.json argument
  • From the current users' home directory: ~/.config/pm2-web/config.json
  • A global configuration file: /etc/pm2-web/config.json

The default configuration file is always loaded and other config files will be applied to the default configuration.

The configuration file(s) loaded and the final configuration object will both be recorded in the logs.

Configuration files are loaded using cjson so comments are ok.

All options can be passed as command line arguments and will override any settings found in configuration files.

Authentication

To use HTTP basic auth, set www:authentication:enabled to true in your configuration file. See the default configuration file for more information.

N.b. Your password will be sent in plain text. If you enable HTTP auth, you should probably enable SSL as well.

SSL support

pm2-web can start a https server if so desired. To do so, set www:ssl:enabled to true in your configuration file and supply your certificate details. If you do not have a SSL certificate, the generate_certificate.sh script in the /certs directory will create a self-signed certificate for you.

Debugging running processes

To debug a running process, node-inspector must be installed and running on the same host as the process.

Specify the port it's running on as the inspector property of pm2:host. E.g.:

{
	"pm2": [{
		"host": "foo.baz.com",
		"inspector": 8080
	}]
}

You should then see a debug icon appear next to the stop/restart/reload icons when the process is running.

Clicking this icon will send a SIGUSR1 signal to the process to put it into debug mode and open node-inspector in a new window.

N.b. you may need to change which source file you are looking at in node-inspector to see anything useful.

Debugging multiple processes

By default node will listen for debugger connections on port 5858. If you attempt to debug multiple processes you must specify different debug ports for them:

$ pm2 start --node-args="--debug=7000" foo.js
$ pm2 start --node-args="--debug=7001" bar.js

Debugging multiple instances

This is not possible because:

$ pm2 start --node-args="--debug=7000" -i 4 foo.js

will start four separate processes all listening on port 7000.

If you are expecting to debug your process, please only start one of them.

Reload/restart processes

Restarting a process stops the current process and starts a new one, dropping connections in the process.

Reloading starts a new process in the background, killing the old process after the new one has initialised which reduces downtime.

N.b. your process must exit cleanly (e.g. close sockets, database connections) otherwise the old process will never be killed.

Hard vs soft reloading

Soft reloading (the default) will cause pm2 to send your process a shutdown message and kill it shortly afterwards. Hard reloading will kill it immediately.

To control this behaviour, specify the following in your config file:

{
	"forceHardReload": false
}

To listen for the shutdown event, add the following to your program:

process.on("message", function(message) {
	if(message == "shutdown") {
		// do tidy up here
	}
});

Resource usage graphs

You can tweak the resource usage graph to be more or less specific. The thinking here is that lots of processes with lots of process usage data will make your browser a bit crashey.

By default it will retain 1000 resource usage measurements of a process (CPU and memory) over a maximum of five days with 40% of the measurements taken in the last 24 hours, 25% from the day before, 10% each from the two days before that and 5% from the day before that.

The update frequency of the graph is controlled by --updateFrequency as detailed above.

--graph.datapoints 1000

The number of data points that will be plotted on the graph in total. If you've got a lot of processes, you may wish to set this to a lowish number to minimise memory consumption in your browser and the pm2-web process itself.

--graph.distribution 40 --graph.distribution 25 --graph.distribution 10 --graph.distribution 10 --graph.distribution 5

The number of --graph.distribution arguments is the number of days worth of data to graph (default 5) and the value is what percentage of --graph.datapoints should be plotted on a given day (the first --graph.distribution argument is today, the second is yesterday, etc).

What this means is that any recent resource usage data will have a more accurate representation in the graph at the cost of consuming more memory and older data will be less accurate but also less likely to crash your browser.

Logs

pm2-web will display log lines emitted by monitored processes after pm2-web itself was started. In order to keep resource usage reasonable by default it will show 1000 log lines.

You can alter this behaviour by specifying --logs:max, so for example to lower this to 500 lines:

--logs:max 500

Release notes

2.0.x

  • Uses 2.x version of pm2-interface, even though it breaks monitoring multiple hosts
  • Shows an error message when attempting to monitor an old/incompatible version of pm2

1.6.x

  • Allow reloading of processes as well as restarting
  • Debug button added to use node-inspector to debug running processes
  • Batch UI updates together in an attempt to improve performance
  • Supports http basic auth
  • Supports serving over HTTPS
  • Serve websockets and UI from a single port to make proxying easier

1.5.x

  • Introduced external configuration file

1.4.x

  • Swapped d3/xCharts for HighCharts due to a memory leak

1.3.x

  • Display logs from processes emitted after pm2-web was started
  • Caches logging output between browser refreshes
  • Respects ANSI colour in logging output

1.2.x

  • Must have been something interesting here

1.1.x

  • Displays graphs of memory and cpu output

1.0.x

  • Initial release
  • Process listing
  • Restarting, stopping & starting processes

Credits

Code by achingbrain, originally based on work done by dunxrion.

Uses pm2 and pm2-interface by unitech.

Special thanks to joewalnes for reconnecting-websocket and Luegg for angularjs-scroll-glue.

More Repositories

1

it

A collection of utilities for making working with iterables more bearable
TypeScript
271
star
2

php5-akismet

A PHP class that enables you use the Akismet anti-spam service in your PHP5 application.
PHP
125
star
3

mongoose-crate

A Mongoose plugin for attaching files to documents.
JavaScript
57
star
4

ssdp

Simple Service Discovery Protocol implemented for Node.js
TypeScript
45
star
5

uint8arrays

Utility methods for dealing with Uint8Arrays
TypeScript
37
star
6

board-io

Allows for boards other than Arduinos loaded with Firmata to be used with johnny-five
JavaScript
22
star
7

mongoose-crate-s3

JavaScript
17
star
8

build-cat

Physical build avatar
JavaScript
14
star
9

mongoose-crate-imagemagick

JavaScript
10
star
10

node-wantsit

Super lightweight dependency injection
JavaScript
9
star
11

jvm.js

A JVM implemented in JavaScript
JavaScript
7
star
12

cpu-stats

Calculates per-core CPU usage of the current computer
JavaScript
7
star
13

less-maven-plugin

Another LESS plugin for Maven
JavaScript
7
star
14

it-multipart

Async iterable http multipart message parser
JavaScript
5
star
15

it-all

Collects all values from an async iterator and returns them as an array
JavaScript
5
star
16

swagger-ui-browserify

Use swagger-ui with browserify
JavaScript
4
star
17

native-fetch

Returns native fetch if available or the node-fetch module if not
JavaScript
4
star
18

mortice

Isomorphic read/write lock that works in single processes, node clusters and web workers
TypeScript
4
star
19

homebridge-esp8266-rf-outlet

Homebridge plugin for RF outlets
C++
4
star
20

esm-vs-cjs

JavaScript
4
star
21

uint8arraylist

Append and consume bytes using only no-copy operations
TypeScript
4
star
22

coercer

Turns objects/arrays full of strings of numbers and booleans into primitives
JavaScript
3
star
23

mongoose-crate-gm

JavaScript
3
star
24

it-last

Returns the last result from an async iterator
JavaScript
3
star
25

bonvoyage

Seaport service discovery and registering via mDNS/Bonjour/zeroconf
JavaScript
3
star
26

bbq

Javascript Ninjery
JavaScript
3
star
27

it-flat-batch

Takes an async iterator that emits variable length arrays and emits them as fixed size batches
JavaScript
3
star
28

mongoose-crate-localfs

JavaScript
3
star
29

it-buffer-stream

An async iterator that emits buffers containing bytes up to a certain length
JavaScript
3
star
30

it-first

Returns the first result from an async iterator
JavaScript
3
star
31

it-stream-types

Typescript types for AsyncIterable sink/source/duplex streams
TypeScript
2
star
32

docker-ipfs-pubsub

JavaScript
2
star
33

ioboard-beaglebone-black

An implementation of ioboard for the BeagleBone Black
JavaScript
2
star
34

footballbot

JavaScript
2
star
35

coveralls-lerna

Collates coverage data generated by monorepos and sends it to coveralls
JavaScript
2
star
36

async-iterator-to-buffer

When passed an async iterator that returns buffers, cat them all together
2
star
37

mongoose-crate-gcs

JavaScript
2
star
38

nano-repository

Simple CRUD wrapper for nano and CouchDB
JavaScript
2
star
39

it-glob

Async iterable filename pattern matcher
JavaScript
2
star
40

brickpi

Node.js bindings for the BrickPi
JavaScript
2
star
41

SimpleHTTPd

Extremely lightweight embedded Cocoa web server
2
star
42

hexify

Turn files into arrays of hex codes
JavaScript
2
star
43

native-abort-controller

Returns native AbortController/AbortSignal if available or the abort-controller module if not
JavaScript
2
star
44

readable-stream-buffer-stream

A readable stream that emits buffers containing bytes up to a certain length
JavaScript
2
star
45

pem-promise

The pem module wrapped in a promises API
JavaScript
1
star
46

wherearewe

Environment detection
JavaScript
1
star
47

node-maestro-ioboard

Pololu Maestro implementation of ioboard
JavaScript
1
star
48

progress-events

Progress events and types
TypeScript
1
star
49

bigboard

BBQjs based ticket/milestone interrogation system
JavaScript
1
star
50

ipfs-unixfs-cli

Simple cli tool to inspect UnixFS metadata from IPFS DAG nodes
JavaScript
1
star
51

dht-delegate-example

Publish non-dag-pb data on the DHT from js-IPFS using a go-IPFS DHT delegate
JavaScript
1
star
52

freeport-promise

A promise to find a free port
TypeScript
1
star
53

puppeteer-frames

JavaScript
1
star
54

mono-repo-bootstrap

A starting point for mono-repo projects
1
star
55

barbara-ngrok

Create an ngrok tunnel to this computer and tweet at me when it's done
JavaScript
1
star
56

nss

Precompiled nss tools
JavaScript
1
star
57

nodebots-of-london-tutorials

Beginner tutorials for NodeBots of London
JavaScript
1
star
58

clockbot

Giant LED clock controller
JavaScript
1
star
59

maven-repo

Maven repository for my various weekend warrior projects
JavaScript
1
star
60

meatmon

Smoking me some brisket
JavaScript
1
star
61

pull-buffer-stream

Emits streams of buffers
JavaScript
1
star
62

munitorum

JavaScript
1
star
63

node-firmata-ioboard

Firmata implementation of ioboard
JavaScript
1
star
64

it-parallel-batch

Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input
JavaScript
1
star
65

output-buffer

Buffers your outputs and calls a function when a linebreak is found
TypeScript
1
star
66

electron-chromedriver

Docker images with electron-chromedriver and a VNC server installed for integration testing your Electron apps
Shell
1
star
67

electron-adventure

A self-guided workshop for learning electron
JavaScript
1
star
68

swagger-ui-browserify-example-v2.0

An example of how to use swagger-ui-browserify with Swagger v2.0 compliant APIs
JavaScript
1
star
69

flex-multi-module-sample

A demo app showing flex-mojos not minding what the parent pom is
ActionScript
1
star
70

wss-demo

Shell
1
star