Skip to content

Commit

Permalink
Merge branch 'development' into bugfix/deploy-ecosystem-filename-exte…
Browse files Browse the repository at this point in the history
…nsion
  • Loading branch information
Unitech committed Oct 6, 2023
2 parents 79687f1 + 7912239 commit dd19e3f
Show file tree
Hide file tree
Showing 18 changed files with 2,303 additions and 50 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/node.js.yml
@@ -0,0 +1,29 @@
# 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: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- 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 test
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -10,7 +10,6 @@ test/child
dist/
*.deb
*.rpm
package-lock.json
.DS_Store
*.swp
*.swo
Expand Down
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

29 changes: 19 additions & 10 deletions README.md
@@ -1,31 +1,40 @@
<div align="center">
<br/>
<a href="http://pm2.keymetrics.io/" title="PM2 Keymetrics link">
<img width=710px src="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png" alt="pm2 logo">
</a>
<br/>
<picture>
<source
srcset="https://raw.githubusercontent.com/Unitech/pm2/master/pres/pm2-v4.png"
media="(prefers-color-scheme: light)"
/>
<source
srcset="https://raw.githubusercontent.com/Unitech/pm2/development/pres/pm2-v4-dark-mode.png"
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.com/Unitech/pm2.svg?branch=master" alt="Build Status"/>
</a>

<br/>
<br/>
<br/>
Expand Down
1 change: 1 addition & 0 deletions lib/API/Deploy.js
Expand Up @@ -68,6 +68,7 @@ module.exports = function(CLI) {
if (!Common.isConfigFile(file)) {
env = args[0];
var defaultConfigNames = [ ...Common.knonwConfigFileExtensions('ecosystem'), 'ecosystem.json5', 'package.json'];

file = Utility.whichFileExists(defaultConfigNames);

if (!file) {
Expand Down
6 changes: 3 additions & 3 deletions lib/API/Modules/TAR.js
Expand Up @@ -18,7 +18,7 @@ module.exports = {
uninstall,
start,
publish,
package
packager
}

/**
Expand Down Expand Up @@ -270,7 +270,7 @@ function getModuleName(module_filepath, cb) {
});
}

function package(module_path, target_path, cb) {
function packager(module_path, target_path, cb) {
var base_folder = path.dirname(module_path)
var module_folder_name = path.basename(module_path)
var pkg = require(path.join(module_path, 'package.json'))
Expand Down Expand Up @@ -316,7 +316,7 @@ function publish(PM2, folder, cb) {

Common.logMod(`Starting publishing procedure for ${module_name}@${pkg.version}`)

package(current_path, target_path, (err, res) => {
packager(current_path, target_path, (err, res) => {
if (err) {
Common.errMod('Can\'t package, exiting')
process.exit(1)
Expand Down
7 changes: 7 additions & 0 deletions lib/API/schema.json
Expand Up @@ -193,6 +193,13 @@
"docDefault": "True",
"docDescription": "Enable or disable auto restart after process failure"
},
"stop_exit_codes": {
"type": [
"array",
"number"
],
"docDescription": "List of exit codes that should allow the process to stop (skip autorestart)."
},
"watch_delay": {
"type": "number",
"docDefault": "True",
Expand Down
2 changes: 1 addition & 1 deletion lib/Common.js
Expand Up @@ -563,7 +563,7 @@ Common.safeExtend = function(origin, add){
if (!add || typeof add != 'object') return origin;

//Ignore PM2's set environment variables from the nested env
var keysToIgnore = ['name', 'exec_mode', 'env', 'args', 'pm_cwd', 'exec_interpreter', 'pm_exec_path', 'node_args', 'pm_out_log_path', 'pm_err_log_path', 'pm_pid_path', 'pm_id', 'status', 'pm_uptime', 'created_at', 'windowsHide', 'username', 'merge_logs', 'kill_retry_time', 'prev_restart_delay', 'instance_var', 'unstable_restarts', 'restart_time', 'axm_actions', 'pmx_module', 'command', 'watch', 'filter_env', 'versioning', 'vizion_runing', 'MODULE_DEBUG', 'pmx', 'axm_options', 'created_at', 'watch', 'vizion', 'axm_dynamic', 'axm_monitor', 'instances', 'automation', 'autorestart', 'unstable_restart', 'treekill', 'exit_code', 'vizion'];
var keysToIgnore = ['name', 'exec_mode', 'env', 'args', 'pm_cwd', 'exec_interpreter', 'pm_exec_path', 'node_args', 'pm_out_log_path', 'pm_err_log_path', 'pm_pid_path', 'pm_id', 'status', 'pm_uptime', 'created_at', 'windowsHide', 'username', 'merge_logs', 'kill_retry_time', 'prev_restart_delay', 'instance_var', 'unstable_restarts', 'restart_time', 'axm_actions', 'pmx_module', 'command', 'watch', 'filter_env', 'versioning', 'vizion_runing', 'MODULE_DEBUG', 'pmx', 'axm_options', 'created_at', 'watch', 'vizion', 'axm_dynamic', 'axm_monitor', 'instances', 'automation', 'autorestart', 'stop_exit_codes', 'unstable_restart', 'treekill', 'exit_code', 'vizion'];

var keys = Object.keys(add);
var i = keys.length;
Expand Down
10 changes: 9 additions & 1 deletion lib/God.js
Expand Up @@ -114,6 +114,7 @@ God.prepare = function prepare (env, cb) {
}
}
God.clusters_db[env.pm_id] = clu
God.registerCron(env)
return cb(null, [ God.clusters_db[env.pm_id] ])
}

Expand Down Expand Up @@ -360,10 +361,17 @@ God.handleExit = function handleExit(clu, exit_code, kill_signal) {
return false;
}

var stopExitCodes = proc.pm2_env.stop_exit_codes !== undefined && proc.pm2_env.stop_exit_codes !== null ? proc.pm2_env.stop_exit_codes : [];
if (!Array.isArray(stopExitCodes)) {
stopExitCodes = [stopExitCodes];
}

var stopping = (proc.pm2_env.status == cst.STOPPING_STATUS
|| proc.pm2_env.status == cst.STOPPED_STATUS
|| proc.pm2_env.status == cst.ERRORED_STATUS)
|| (proc.pm2_env.autorestart === false || proc.pm2_env.autorestart === "false");
|| (proc.pm2_env.autorestart === false || proc.pm2_env.autorestart === "false")
|| (stopExitCodes.map((strOrNum) => typeof strOrNum === 'string' ? parseInt(strOrNum, 10) : strOrNum)
.includes(exit_code));

var overlimit = false;

Expand Down
1 change: 1 addition & 0 deletions lib/binaries/CLI.js
Expand Up @@ -77,6 +77,7 @@ commander.version(pkg.version)
.option('--no-color', 'skip colors')
.option('--no-vizion', 'start an app without vizion feature (versioning control)')
.option('--no-autorestart', 'start an app without automatic restart')
.option('--stop-exit-codes <exit_codes...>', 'specify a list of exit codes that should skip automatic restart')
.option('--no-treekill', 'Only kill the main process, not detached children')
.option('--no-pmx', 'start an app without pmx')
.option('--no-automation', 'start an app without pmx')
Expand Down
1 change: 1 addition & 0 deletions lib/binaries/Runtime4Docker.js
Expand Up @@ -18,6 +18,7 @@ commander.version(pkg.version)
.option('-i --instances <number>', 'launch [number] of processes automatically load-balanced. Increase overall performances and performance stability.')
.option('--secret [key]', '[MONITORING] PM2 plus secret key')
.option('--no-autorestart', 'start an app without automatic restart')
.option('--stop-exit-codes <exit_codes...>', 'specify a list of exit codes that should skip automatic restart')
.option('--node-args <node_args>', 'space delimited arguments to pass to node in cluster mode - e.g. --node-args="--debug=7001 --trace-deprecation"')
.option('-n --name <name>', 'set a <name> for script')
.option('--max-memory-restart <memory>', 'specify max memory amount used to autorestart (in octet or use syntax like 100M)')
Expand Down

0 comments on commit dd19e3f

Please sign in to comment.