Skip to content

Commit 9fd9f22

Browse files
committed
merge
2 parents a092db2 + 8d9ecd2 commit 9fd9f22

File tree

12 files changed

+255
-399
lines changed

12 files changed

+255
-399
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
<br/><br/>
2222

2323

24-
<a title="Donate" href="https://explorer.kaspa.org/addresses/kaspa:qr2gxmun87mc8wt8adegy6fulvpfdjgsa8zcdxyulvzzr2utra3jv4s8txkq9">
25-
<img src="https://img.shields.io/badge/donation-kaspa-green" alt="Donate"/>
26-
</a>
27-
2824
<a title="PM2 Downloads" href="https://npm-stat.com/charts.html?package=pm2&from=2018-01-01&to=2023-08-01">
2925
<img src="https://img.shields.io/npm/dm/pm2" alt="Downloads per Month"/>
3026
</a>

lib/API.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class API {
322322
if (!opts) opts = {};
323323

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

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

16121612
delete appConf.exec_mode;
16131613

1614-
if (util.isArray(appConf.watch) && appConf.watch.length === 0) {
1614+
if (Array.isArray(appConf.watch) && appConf.watch.length === 0) {
16151615
if (!~opts.rawArgs.indexOf('--watch'))
16161616
delete appConf.watch
16171617
}
@@ -1630,6 +1630,8 @@ class API {
16301630
delete appConf.vizion;
16311631
if (appConf.automation === true)
16321632
delete appConf.automation;
1633+
if (appConf.autostart === true)
1634+
delete appConf.autostart;
16331635
if (appConf.autorestart === true)
16341636
delete appConf.autorestart;
16351637

lib/API/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@
187187
"docDefault" : "True",
188188
"docDescription": "Enable or disable the versioning metadatas (vizion library)"
189189
},
190+
"autostart": {
191+
"type": "boolean",
192+
"default": true,
193+
"docDefault": "True",
194+
"docDescription": "Enable or disable auto start when adding process"
195+
},
190196
"autorestart": {
191197
"type": "boolean",
192198
"default": true,

lib/Common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Common.getConfigFileCandidates = function (name) {
304304
* @return {Object} config object
305305
*/
306306
Common.parseConfig = function(confObj, filename) {
307-
var yamljs = require('yamljs');
307+
var yamljs = require('js-yaml');
308308
var vm = require('vm');
309309

310310
var isConfigFile = Common.isConfigFile(filename);
@@ -323,7 +323,7 @@ Common.parseConfig = function(confObj, filename) {
323323
});
324324
}
325325
else if (isConfigFile == 'yaml') {
326-
return yamljs.parse(confObj.toString());
326+
return yamljs.load(confObj.toString());
327327
}
328328
else if (isConfigFile == 'js' || isConfigFile == 'mjs') {
329329
var confPath = require.resolve(path.resolve(filename));
@@ -565,7 +565,7 @@ Common.safeExtend = function(origin, add){
565565
if (!add || typeof add != 'object') return origin;
566566

567567
//Ignore PM2's set environment variables from the nested env
568-
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'];
568+
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'];
569569

570570
var keys = Object.keys(add);
571571
var i = keys.length;

lib/God.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ God.executeApp = function executeApp(env, cb) {
168168

169169
Utility.extend(env_copy, env_copy.env);
170170

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

212212
God.registerCron(env_copy)
213213

214+
if (env_copy['autostart'] === false) {
215+
var clu = {pm2_env: env_copy, process: {pid: 0}};
216+
God.clusters_db[env_copy.pm_id] = clu;
217+
return cb(null, clu);
218+
}
219+
214220
/** Callback when application is launched */
215221
var readyCb = function ready(proc) {
216222
// If vizion enabled run versioning retrieval system

lib/Watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function ClusterMode(God) {
2929

3030
var watch = pm2_env.watch
3131

32-
if(typeof watch == 'boolean' || util.isArray(watch) && watch.length === 0)
32+
if(typeof watch == 'boolean' || Array.isArray(watch) && watch.length === 0)
3333
watch = pm2_env.pm_cwd;
3434

3535
log('Watching %s', watch);

lib/binaries/CLI.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ commander.version(pkg.version)
7676
.option('--watch-delay <delay>', 'specify a restart delay after changing files (--watch-delay 4 (in sec) or 4000ms)')
7777
.option('--no-color', 'skip colors')
7878
.option('--no-vizion', 'start an app without vizion feature (versioning control)')
79+
.option('--no-autostart', 'add an app without automatic start')
7980
.option('--no-autorestart', 'start an app without automatic restart')
8081
.option('--stop-exit-codes <exit_codes...>', 'specify a list of exit codes that should skip automatic restart')
8182
.option('--no-treekill', 'Only kill the main process, not detached children')

lib/binaries/DevCLI.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function run(cmd, opts) {
6565
var timestamp = opts.timestamp;
6666

6767
opts.watch = true;
68+
opts.autostart = true;
6869
opts.autorestart = true;
6970
opts.restart_delay = 1000
7071
if (opts.autoExit)

lib/binaries/Runtime4Docker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ commander.version(pkg.version)
1717
.description('pm2-runtime is a drop-in replacement Node.js binary for containers')
1818
.option('-i --instances <number>', 'launch [number] of processes automatically load-balanced. Increase overall performances and performance stability.')
1919
.option('--secret [key]', '[MONITORING] PM2 plus secret key')
20+
.option('--no-autostart', 'add an app without automatic start')
2021
.option('--no-autorestart', 'start an app without automatic restart')
2122
.option('--stop-exit-codes <exit_codes...>', 'specify a list of exit codes that should skip automatic restart')
2223
.option('--node-args <node_args>', 'space delimited arguments to pass to node in cluster mode - e.g. --node-args="--debug=7001 --trace-deprecation"')

0 commit comments

Comments
 (0)