Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remz committed Feb 2, 2024
2 parents 365b426 + a092db2 commit 3bec0a5
Show file tree
Hide file tree
Showing 92 changed files with 2,878 additions and 787 deletions.
9 changes: 1 addition & 8 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<!--
Your issue may already be reported!
Please search on the [issue tracker](https://github.com/Unitech/pm2/search?type=Issues) before creating one.
-->

## What's going wrong?

## How could we reproduce this issue?

## Supporting information

<!--
Please run the following command (available on PM2 >= 2.6)
-->
```
# Run the following commands
$ pm2 report
```
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
matrix:
node-version: [20.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: sudo apt install python3
- run: sudo apt install php-cli
- run: npm install
- run: npm run test:e2e
- run: npm run test:unit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ test/child
dist/
*.deb
*.rpm
package-lock.json
.DS_Store
*.swp
*.swo
Expand Down
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

52 changes: 50 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
## 5.1.2 MendriX:

## 5.3.2 (MendriX):
- fix: pipe names in Windows were not unique for each instance (added _suffix made from hashed PM2_HOME path)

## 5.3.1

- #5686 Switch from Travis CI to Github Actions
- #5680 Fixed reserved keyword for ES6 Strict Mode when Bundling @juaneth
- #5683 update badges
- #5684 auto switch light and dark mode logos
- #5678 Bugfix/deploy ecosystem filename extension / esm module default ecosystem config name @TeleMediaCC
- #5660 Fix matching logic for logs from namespace when lines = 0 @bawjensen
- fix "vulnerabilities" in axios module

## 5.3.0

- fix: replace non-working condition that blocks flush from clearing the logs #5533 @Sailboat265
- fix: ESM script loader #5524 @BlueWater86

## 5.2.2

- fix: correct pm2 ls display when there is a (very) long process id (@dko-slapdash)
- typo: corrections

## 5.2.1

- fix cluster error avoiding process restart (#5396)
- ensure increment_var value is a number (#5435)
- update dependencies
- add node latest to travis testing

## 5.2.0

- replace node-cron by croner (#5183 #5035)
- upgrade mocha deps
- fix pm2 report when daemon not running
- remove semver check for legacy node.js versions
- update node version in setup.deb.sh by using lts (#5201) + openrc
- replace legacy util._extend by Object.assign (#5239)
- add missing start options types (#5242)
- recursive detection of package.json (#5267)
- make tarball module uninstall cross-platform (#5269)
- Fix unnecessary "ENOENT" console.error when serving a spa (#5272)
- fix: used env variable instead of hardcode datetime format (#5277)
- copyright update (#5278)
- fix: remove constants import from VersionCheck (not needed) (#5279)
- Reduce async import (#5280)

## 5.1.2

- easily disable cron-restart strategy via `$ pm2 restart --cron-restart 0`
- allow to update cron-restart on restart

## 5.1.1

- remove fast-printf and replace with sprintfjs
Expand Down
80 changes: 47 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
<div align="center">
<br/>
<a href="http://pm2.keymetrics.io/" title="PM2 Keymetrics link">
<img width=710px src="https://raw.githubusercontent.com/Unitech/pm2/development/pres/pm2-v4.png" alt="pm2 logo">
</a>
<br/>
<picture>
<source
srcset="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png"
width=710px
media="(prefers-color-scheme: light)"
/>
<source
srcset="https://raw.githubusercontent.com/Unitech/pm2/development/pres/pm2-v4-dark-mode.png"
width=710px
media="(prefers-color-scheme: dark), (prefers-color-scheme: no-preference)"
/>
<img src="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png" />
</picture>

<br/>
<br/>
<b>P</b>(rocess) <b>M</b>(anager) <b>2</b><br/>
<i>Runtime Edition</i>
<br/><br/>


<a title="PM2 Downloads">

<a title="Donate" href="https://explorer.kaspa.org/addresses/kaspa:qr2gxmun87mc8wt8adegy6fulvpfdjgsa8zcdxyulvzzr2utra3jv4s8txkq9">
<img src="https://img.shields.io/badge/donation-kaspa-green" alt="Donate"/>
</a>

<a title="PM2 Downloads" href="https://npm-stat.com/charts.html?package=pm2&from=2018-01-01&to=2023-08-01">
<img src="https://img.shields.io/npm/dm/pm2" alt="Downloads per Month"/>
</a>

<a title="PM2 Downloads">
<a title="PM2 Downloads" href="https://npm-stat.com/charts.html?package=pm2&from=2018-01-01&to=2023-08-01">
<img src="https://img.shields.io/npm/dy/pm2" alt="Downloads per Year"/>
</a>

<a href="https://badge.fury.io/js/pm2" title="NPM Version Badge">
<img src="https://badge.fury.io/js/pm2.svg" alt="npm version">
</a>

<a href="https://travis-ci.com/github/Unitech/pm2" title="PM2 Tests">
<img src="https://travis-ci.org/Unitech/pm2.svg?branch=master" alt="Build Status"/>
</a>

<br/>
<br/>
<br/>
Expand All @@ -40,7 +51,7 @@ Starting an application in production mode is as easy as:
$ pm2 start app.js
```

PM2 is constantly assailed by [more than 1800 tests](https://travis-ci.org/Unitech/pm2).
PM2 is constantly assailed by [more than 1800 tests](https://github.com/Unitech/pm2/actions/workflows/node.js.yml).

Official website: [https://pm2.keymetrics.io/](https://pm2.keymetrics.io/)

Expand All @@ -55,7 +66,7 @@ With NPM:
$ npm install pm2 -g
```

You can install Node.js easily with [NVM](https://riptutorial.com/node-js/example/4578/using-node-version-manager--nvm-) or [ASDF](https://blog.natterstefan.me/how-to-use-multiple-node-version-with-asdf)
You can install Node.js easily with [NVM](https://github.com/nvm-sh/nvm#installing-and-updating) or [FNM](https://github.com/Schniz/fnm).

### Start an application

Expand All @@ -71,7 +82,7 @@ Your app is now daemonized, monitored and kept alive forever.

Once applications are started you can manage them easily:

![Process listing](https://github.com/unitech/pm2/raw/master/pres/pm2-list.png)
![Process listing](https://github.com/Unitech/pm2/raw/master/pres/pm2-ls-v2.png)

To list all running applications:

Expand Down Expand Up @@ -99,13 +110,14 @@ To monitor logs, custom metrics, application information:
$ pm2 monit
```


[More about Process Management](https://pm2.keymetrics.io/docs/usage/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).

![Framework supported](https://raw.githubusercontent.com/Unitech/PM2/master/pres/cluster.png)

Starting a Node.js application in cluster mode that will leverage all CPUs available:

```bash
Expand All @@ -122,10 +134,6 @@ 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](https://raw.githubusercontent.com/Unitech/PM2/master/pres/cluster-support.png)

[More informations about how PM2 make clustering easy](https://pm2.keymetrics.io/docs/usage/cluster-mode/)

### Container Support
Expand All @@ -140,6 +148,19 @@ CMD [ "pm2-runtime", "npm", "--", "start" ]

[Read More about the dedicated integration](https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)

### Host monitoring speedbar

PM2 allows to monitor your host/server vitals with a monitoring speedbar.

To enable host monitoring:

```bash
$ pm2 set pm2:sysmonit true
$ pm2 update
```

![Framework supported](https://raw.githubusercontent.com/Unitech/PM2/master/pres/vitals.png)

### Terminal Based Monitoring

![Monit](https://github.com/Unitech/pm2/raw/master/pres/pm2-monit.png)
Expand Down Expand Up @@ -171,11 +192,17 @@ $ pm2 flush # Flush all logs
$ pm2 reloadLogs # Reload all logs
```

To enable log rotation install the following module

```bash
$ pm2 install pm2-logrotate
```

[More about log management](https://pm2.keymetrics.io/docs/usage/log-management/)

### Startup Scripts Generation

PM2 can generates and configure a Startup Script to keep PM2 and your processes alive at every server restart.
PM2 can generate and configure a Startup Script to keep PM2 and your processes alive at every server restart.

Init Systems Supported: **systemd**, **upstart**, **launchd**, **rc.d**

Expand All @@ -192,19 +219,6 @@ $ pm2 unstartup

[More about Startup Scripts Generation](https://pm2.keymetrics.io/docs/usage/startup/)

### PM2 Modules

PM2 embeds a simple and powerful module system. Installing a module is straightforward:

```bash
$ pm2 install <module_name>
```

Here are some PM2 compatible modules (standalone Node.js applications managed by PM2):

[**pm2-logrotate**](https://www.npmjs.com/package/pm2-logrotate) automatically rotate logs and limit logs size<br/>
[**pm2-server-monit**](https://www.npmjs.com/package/pm2-server-monit) monitor the current server with more than 20+ metrics and 8 actions<br/>

### Updating PM2

```bash
Expand Down
4 changes: 2 additions & 2 deletions constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013 the PM2 project authors. All rights reserved.
* Copyright 2013-2022 the PM2 project authors. All rights reserved.
* Use of this source code is governed by a license that
* can be found in the LICENSE file.
*/
Expand Down Expand Up @@ -109,4 +109,4 @@ var csts = {

};

module.exports = util._extend(csts, path_structure);
module.exports = Object.assign(csts, path_structure);
2 changes: 1 addition & 1 deletion examples/cluster-http/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('hey');
}).listen(process.env.PORT || 8089, '0.0.0.0', function() {
console.log('App listening on port %d', server.address().port);
console.log('App listening on port 8089');
});
9 changes: 9 additions & 0 deletions examples/send-msg/pm2-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

process.on('message', function(packet) {
process.send({
type : 'process:msg',
data : {
success : true
}
});
});
29 changes: 29 additions & 0 deletions examples/send-msg/pm2-msg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

const pm2 = require('../..')

console.log(pm2)

pm2.connect(function() {
pm2.sendDataToProcessId({
// id of procces from "pm2 list" command or from pm2.list(errback) method
id : '1',

// process:msg will be send as 'message' on target process
type : 'process:msg',

// Data to be sent
data : {
some : 'data'
},

topic: true
}, function(err, res) {
})
})

// Listen to messages from application
pm2.launchBus(function(err, pm2_bus) {
pm2_bus.on('process:msg', function(packet) {
console.log(packet)
})
})
16 changes: 16 additions & 0 deletions examples/send-msg/t2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

var tx2 = require('tx2')
var http = require('http')

var meter = tx2.meter({
name : 'req/sec',
samples : 1,
timeframe : 60
})

http.createServer(function (req, res) {
meter.mark()
res.writeHead(200, {'Content-Type': 'text/plain'})
res.write('Hello World!')
res.end()
}).listen(6001)
Loading

0 comments on commit 3bec0a5

Please sign in to comment.