https://github.com/jdforsythe/pm2-check-express
Create express endpoints for health check and stats with pm2
https://github.com/jdforsythe/pm2-check-express
express health-check node node-js node-module nodejs pm2 stats
Last synced: about 2 months ago
JSON representation
Create express endpoints for health check and stats with pm2
- Host: GitHub
- URL: https://github.com/jdforsythe/pm2-check-express
- Owner: jdforsythe
- Created: 2016-07-09T17:05:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-11T12:08:43.000Z (almost 10 years ago)
- Last Synced: 2025-03-17T21:43:25.679Z (about 1 year ago)
- Topics: express, health-check, node, node-js, node-module, nodejs, pm2, stats
- Language: JavaScript
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pm2-check-express
Create express endpoints for health check and stats with pm2
# Install
```sh
$ npm install --save pm2-check-express
```
# Usage
```js
const express = require('express');
const app = express();
const pm2CheckRoutes = require('pm2-check-express');
app.use('/', function(req, res, next) {
//
});
pm2CheckRoutes(app, {
healthUrl: '/health',
statsUrl: '/stats',
timestampFormat: 'MM/DD/YY h:mm:ss a'
});
```
This will expose:
- `/health` route which returns `200` if all processes are online or `500` if **any** process is not online
- `/stats` route which returns a hash of stats:
```js
{
healthy: true, // same as the /health route, but `true/false`
system: {
freeMemory: '2048.00MB',
totalMemory: '4096.00MB',
usedMemory: '2048.00MB',
usedMemoryPercent: 50.00,
cpuPercent: .36
},
processes: [
pid: 12345,
name: 'server',
instances: 1,
status: 'online',
lastStart: '07/04/2016 7:22 am',
lastStartAgo: '5 days ago',
firstStart: '07/01/2016 6:44 pm',
firstStartAgo: '8 days ago',
httpLatency: 155,
loopDelay: {
value: "5.1ms",
agg_type: "avg",
alert: {}
},
restarts: 1,
memory: 45596672,
cpu: 12
]
}