Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed May 23, 2024
2 parents a092db2 + 8d9ecd2 commit 9fd9f22
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 399 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
<br/><br/>


<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>
Expand Down
6 changes: 4 additions & 2 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class API {
if (!opts) opts = {};

var that = this;
if (util.isArray(opts.watch) && opts.watch.length === 0)
if (Array.isArray(opts.watch) && opts.watch.length === 0)
opts.watch = (opts.rawArgs ? !!~opts.rawArgs.indexOf('--watch') : !!~process.argv.indexOf('--watch')) || false;

if (Common.isConfigFile(cmd) || (typeof(cmd) === 'object')) {
Expand Down Expand Up @@ -1611,7 +1611,7 @@ class API {

delete appConf.exec_mode;

if (util.isArray(appConf.watch) && appConf.watch.length === 0) {
if (Array.isArray(appConf.watch) && appConf.watch.length === 0) {
if (!~opts.rawArgs.indexOf('--watch'))
delete appConf.watch
}
Expand All @@ -1630,6 +1630,8 @@ class API {
delete appConf.vizion;
if (appConf.automation === true)
delete appConf.automation;
if (appConf.autostart === true)
delete appConf.autostart;
if (appConf.autorestart === true)
delete appConf.autorestart;

Expand Down
6 changes: 6 additions & 0 deletions lib/API/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@
"docDefault" : "True",
"docDescription": "Enable or disable the versioning metadatas (vizion library)"
},
"autostart": {
"type": "boolean",
"default": true,
"docDefault": "True",
"docDescription": "Enable or disable auto start when adding process"
},
"autorestart": {
"type": "boolean",
"default": true,
Expand Down
6 changes: 3 additions & 3 deletions lib/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Common.getConfigFileCandidates = function (name) {
* @return {Object} config object
*/
Common.parseConfig = function(confObj, filename) {
var yamljs = require('yamljs');
var yamljs = require('js-yaml');
var vm = require('vm');

var isConfigFile = Common.isConfigFile(filename);
Expand All @@ -323,7 +323,7 @@ Common.parseConfig = function(confObj, filename) {
});
}
else if (isConfigFile == 'yaml') {
return yamljs.parse(confObj.toString());
return yamljs.load(confObj.toString());
}
else if (isConfigFile == 'js' || isConfigFile == 'mjs') {
var confPath = require.resolve(path.resolve(filename));
Expand Down Expand Up @@ -565,7 +565,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', 'stop_exit_codes', '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', 'autostart', 'autorestart', 'stop_exit_codes', 'unstable_restart', 'treekill', 'exit_code', 'vizion'];

var keys = Object.keys(add);
var i = keys.length;
Expand Down
8 changes: 7 additions & 1 deletion lib/God.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ God.executeApp = function executeApp(env, cb) {

Utility.extend(env_copy, env_copy.env);

env_copy['status'] = cst.LAUNCHING_STATUS;
env_copy['status'] = env.autostart ? cst.LAUNCHING_STATUS : cst.STOPPED_STATUS;
env_copy['pm_uptime'] = Date.now();
env_copy['axm_actions'] = [];
env_copy['axm_monitor'] = {};
Expand Down Expand Up @@ -211,6 +211,12 @@ God.executeApp = function executeApp(env, cb) {

God.registerCron(env_copy)

if (env_copy['autostart'] === false) {
var clu = {pm2_env: env_copy, process: {pid: 0}};
God.clusters_db[env_copy.pm_id] = clu;
return cb(null, clu);
}

/** Callback when application is launched */
var readyCb = function ready(proc) {
// If vizion enabled run versioning retrieval system
Expand Down
2 changes: 1 addition & 1 deletion lib/Watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function ClusterMode(God) {

var watch = pm2_env.watch

if(typeof watch == 'boolean' || util.isArray(watch) && watch.length === 0)
if(typeof watch == 'boolean' || Array.isArray(watch) && watch.length === 0)
watch = pm2_env.pm_cwd;

log('Watching %s', watch);
Expand Down
1 change: 1 addition & 0 deletions lib/binaries/CLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ commander.version(pkg.version)
.option('--watch-delay <delay>', 'specify a restart delay after changing files (--watch-delay 4 (in sec) or 4000ms)')
.option('--no-color', 'skip colors')
.option('--no-vizion', 'start an app without vizion feature (versioning control)')
.option('--no-autostart', 'add an app without automatic start')
.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')
Expand Down
1 change: 1 addition & 0 deletions lib/binaries/DevCLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function run(cmd, opts) {
var timestamp = opts.timestamp;

opts.watch = true;
opts.autostart = true;
opts.autorestart = true;
opts.restart_delay = 1000
if (opts.autoExit)
Expand Down
1 change: 1 addition & 0 deletions lib/binaries/Runtime4Docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ commander.version(pkg.version)
.description('pm2-runtime is a drop-in replacement Node.js binary for containers')
.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-autostart', 'add an app without automatic start')
.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"')
Expand Down
Loading

0 comments on commit 9fd9f22

Please sign in to comment.