diff --git a/examples/args.js b/examples/args.js index d7d66890..7ca2d5b0 100644 --- a/examples/args.js +++ b/examples/args.js @@ -3,7 +3,8 @@ process.argv.forEach(function (val, index, array) { console.log(index + ': ' + val); }); +console.log('Argv2 = ', process.argv[2]); + setInterval(function() { console.log('HERE ARE MY ARGS !!! = ', process.argv); }, 800); - diff --git a/examples/axm/probes.js b/examples/axm/probes.js index 5eafc670..cedeb183 100644 --- a/examples/axm/probes.js +++ b/examples/axm/probes.js @@ -84,7 +84,14 @@ setInterval(function() { }, 1500); +axm.catchAll(); +axm.action('throw error', function(reply) { + setTimeout(function() { + console.log('log message from echo auto kill'); + throw new Error('Exitasdsadasdsda unacepted 222222 !!'); + }, 2000); +}); axm.action('dec', function(reply) { diff --git a/examples/start-args.js b/examples/start-args.js new file mode 100644 index 00000000..416e1c8e --- /dev/null +++ b/examples/start-args.js @@ -0,0 +1,11 @@ + + +var pm2 = require('..'); + +pm2.connect(function() { + pm2.start(__dirname + '/args.js', { + scriptArgs : ['-i', 'sisi', '-x', 'toto'] + }, function(err, res) { + console.log(arguments); + }); +}); diff --git a/lib/CLI.js b/lib/CLI.js index 4e391bd4..9f8a4b38 100644 --- a/lib/CLI.js +++ b/lib/CLI.js @@ -78,9 +78,13 @@ CLI.start = function(script, opts, cb) { delete conf.args; var argsIndex; + if (opts.rawArgs && (argsIndex = opts.rawArgs.indexOf('--')) >= 0) { conf.args = opts.rawArgs.slice(argsIndex + 1); } + else if (opts.scriptArgs) { + conf.args = opts.scriptArgs; + } conf.script = script;