diff --git a/lib/API.js b/lib/API.js index 8424ef79a..f53c34122 100644 --- a/lib/API.js +++ b/lib/API.js @@ -868,6 +868,8 @@ class API { // Here we pick only the field we want from the CLI when starting a JSON appConf.forEach(function(app) { + if (!app.env) { app.env = {}; } + app.env.io = app.io; // --only if (opts.only && opts.only != app.name) return false; @@ -911,6 +913,7 @@ class API { * and act on them depending on action */ async.eachLimit(Object.keys(proc_list), conf.CONCURRENT_ACTIONS, function(proc_name, next) { + // Skip app name (--only option) if (apps_name.indexOf(proc_name) == -1) return next(); diff --git a/lib/API/schema.json b/lib/API/schema.json index 063ffcdda..94ef70e03 100644 --- a/lib/API/schema.json +++ b/lib/API/schema.json @@ -304,5 +304,9 @@ }, "write": { "type": "boolean" + }, + "io": { + "type": "object", + "docDescription": "Specify apm values and configuration" } } diff --git a/lib/ProcessUtils.js b/lib/ProcessUtils.js index 0cc84f3ba..1f0b77032 100644 --- a/lib/ProcessUtils.js +++ b/lib/ProcessUtils.js @@ -1,14 +1,28 @@ +'use strict' + module.exports = { injectModules: function() { if (process.env.pmx !== 'false') { const pmx = require('@pm2/io'); - pmx.init({ + + let conf = {}; + + if (process.env.io) { + const io = JSON.parse(process.env.io); + conf = io.conf ? io.conf : conf; + } + + let defaultConf = { transactions: (process.env.trace === 'true' || process.env.deep_monitoring === 'true') || false, http: process.env.km_link === 'true' || false, v8: process.env.v8 === 'true' || process.env.deep_monitoring === 'true' || false, event_loop_dump: process.env.event_loop_inspector === 'true' || process.env.deep_monitoring === 'true' || false, deep_metrics: process.env.deep_monitoring === 'true' || false - }); + }; + + Object.assign(conf, defaultConf); + + pmx.init(conf); if(require('semver').satisfies(process.versions.node, '>= 8.0.0')) { var url = '';